您的位置:首页 > 编程语言 > PHP开发

php strtotime()函数的用法

2020-06-29 17:19 197 查看

(注)strtotime()是把时间日期字符串转化为时间戳的格式,可以和date()一起使用。如:

[code]<?php
echo(strtotime("now") . "<br>");
echo(strtotime("15 October 1980") . "<br>");
echo(strtotime("+5 hours") . "<br>");
echo(strtotime("+1 week") . "<br>");
echo(strtotime("+1 week 3 days 7 hours 5 seconds") . "<br>");
echo(strtotime("next Monday") . "<br>");
echo(strtotime("last Sunday"));
?>

输出:

1593421414
1473004800
1593439414
1594026214
1594310619
1593964800
1593273600

与date()一起使用

echo date('Y-m-d', strtotime( '-5 day', strtotime(now)));    //输出2020-06-24(注)

echo date('Y-m-d h:i', strtotime( '-1 minutes'));  

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: