Skip to content

Commit

Permalink
add 间隔时间
Browse files Browse the repository at this point in the history
  • Loading branch information
cexll committed May 11, 2021
1 parent fe3bcef commit 5a562b3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/DateHelper.php
Expand Up @@ -356,12 +356,24 @@ public static function getChineseWeek(string $key = null): ?string
];
return $array[$key] ?? null;
}

public static function timeToDate($time = ''): string
{
if (!$time) {
$time = time();
}
return date('Y-m-d H:i:s', $time);
}

/**
* 计算开始时间与结束时间的间隔天数
*
* @param integer $startTime
* @param integer $endTime
* @return integer
*/
public static function calcDateInterval(int $startTime, int $endTime): int
{
return (int)(($endTime - $startTime) / 60 / 60 / 24);
}
}

0 comments on commit 5a562b3

Please sign in to comment.