php strtotime 函数UNIX时间戳

Ilona ·
更新时间:2024-09-20
· 659 次阅读

如果 time 的格式是绝对时间则 now 参数不起作用。如果 time 的格式是相对时间则其所相对的时间由 now 提供,或者如果未提供 now 参数时用当前时间。失败时返回 -1。
<?php
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";
?><?php
$str = 'Not Good';
if (($timestamp = strtotime($str)) === -1) {
echo "The string ($str) is bogus";
} else {
echo "$str == ". date('l dS of F Y h:i:s A',$timestamp);
}
?>
这个效果和用mktime()是一样的. 您可能感兴趣的文章:非常全面的php日期时间运算汇总php中日期加减法运算实现代码PHP时间戳 strtotime()使用方法和技巧PHP下获取上个月、下个月、本月的日期(strtotime,date)php使用strtotime和date函数判断日期是否有效代码分享PHP使用strtotime获取上个月、下个月、本月的日期php使用date和strtotime函数输出指定日期的方法php强大的时间转换函数strtotimePHP中strtotime函数使用方法详解PHP使用strtotime计算两个给定日期之间天数的方法js模仿php中strtotime()与date()函数实现方法php中strtotime函数用法详解PHP实现针对日期,月数,天数,周数,小时,分,秒等的加减运算示例【基于strtotime】



strtotime unix时间戳 unix时间 unix PHP

需要 登录 后方可回复, 如果你还没有账号请 注册新账号