加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > PHP > 正文

php strtotime 函数UNIX时间戳

发布时间:2020-05-24 23:30:52 所属栏目:PHP 来源:互联网
导读:int strtotime ( string time [, int now])本函数预期接受一个包含英文日期格式的字符串并尝试将其解析为 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()是一样的.

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读