【PHP】获取时间
由于我总是很快忘记时间戳转换为过期和 time()、strtotime() 等函数的作用,因此写下备忘录。
日期(时间戳→日时)
请返回日期字符串。
请将时间戳转换为字符串日期。
获取当前时间
print date('Y/m/d');//20xx/x/x/
将时间戳转换为字符串
$timeStamp=time();
print date('Y/m/d h:i:s',$timeStamp);
将日时转换为时间戳的函数
转换英文日期形式为Unix时间戳。
将日期转换为时间戳。
句来源兼职工作可以帮助学生在学习的同时挣取零花钱。
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";
时间
返回当前的Unix时间戳。
以下是一个例子
print time();