侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

php strtotime 函数UNIX时间戳

2023-12-13 星期三 / 0 评论 / 0 点赞 / 45 阅读 / 833 字

如果 time 的格式是绝对时间则 now 参数不起作用。如果 time 的格式是相对时间则其所相对的时间由 now 提供,或者如果未提供 now 参数时用当前时间。失败时返回 -1。 <?php echo strtot

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

广告 广告

评论区