-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathhelper.php
48 lines (45 loc) · 974 Bytes
/
helper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* Created by PhpStorm.
* User: 小粽子
* Date: 2018/12/13
* Time: 10:23
*/
if (!function_exists('convertSize')) {
/**
* 转换byte
*
* @param $size
* @return string
*/
function convertSize($size)
{
$arr = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];
$i = floor(log($size, 1024));
return round($size / pow(1024, ($i)), 2) . $arr[(int)$i];
}
}
if (!function_exists('timeUsage')) {
/**
* 计算耗时
*
* @param $t1
* @param $t2
* @return string
*/
function timeUsage($t1, $t2)
{
$t = $t2 - $t1;
if ($t < 60) {
return "您花了{$t}秒";
} elseif ($t < 60 * 60) {
$t = $t / 60;
return "您花了{$t}分钟";
} elseif ($t < 60 * 60 * 24) {
$t = $t / 60 * 60;
return "您花了{$t}小时";
}else {
return "还未支持。。。";
}
}
}