当前位置:首页 > PHP教程 > PHP高级教程

php strtotime 函数UNIX时间戳

如果 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()是一样的.

【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!