使用PHP 获取时间今天明天昨天时间戳

strtotime()函数的作用是将日期描述解析为Unix时间戳

Unix时间戳:自January 1 1970 00:00:00 GMT起的秒数

PHP获取时间戳:
今天:
$time = time();
print_r(date('Y-m-d h:i:s', $time));
昨天:
$time = strtotime('-1 day');
print_r(date('Y-m-d h:i:s', $time));
明天:
$time = strtotime('+1 day');
print_r(date('Y-m-d', $time));
一星期后:
$time = strtotime('+1 week');
print_r(date('Y-m-d', $time));
一周零两天四小时两秒后:
$time = strtotime('+1 week 2 days 4 hours 2 seconds');
print_r(date('Y-m-d G:H:s', $time));
下个星期五:
$time = strtotime('next Friday');
print_r(date('Y-m-d', $time));
上周一:
$time = strtotime('last Monday');
print_r(date('Y-m-d', $time));
一个月前:
$time = strtotime('last month');
print_r(date('Y-m-d', $time));
一个月后:
$time = strtotime('+1 month');
print_r(date('Y-m-d', $time));
一年后:
$time = strtotime('+1 year');
print_r(date('Y-m-d', $time));

你可能感兴趣的:(PHP,PHP函数)