PHP 日期时间函数

145 阅读1分钟

time

time(): int

返回当前时间戳,单位:秒

date

date(string $format, int $timestamp = ?): string

格式化本地时间

$timestamp 是可选的,如果没有给出时间戳,使用本地当前时间

$format 格式字符串可以识别的字符见这里

strtotime

strtotime(string $datetime, int $now = time()): int

范例:

strtotime("Monday this week"); // 本周一
strtotime("Sunday this week"); // 本周日