当前位置:Gxlcms > PHP教程 > php中的UNIX时间戳函数strtotime

php中的UNIX时间戳函数strtotime

时间:2021-07-01 10:21:17 帮助过:21人阅读

  1. echo strtotime ("now"), "\n";
  2. echo strtotime ("10 September 2000"), "\n";
  3. echo strtotime ("+1 day"), "\n";
  4. echo strtotime ("+1 week"), "\n";
  5. echo strtotime ("+1 week 2 days 4 hours 2 seconds"), "\n";
  6. echo strtotime ("next Thursday"), "\n";
  7. echo strtotime ("last Monday"), "\n";
  8. ?>

例2,

  1. $str = 'Not Good';
  2. if (($timestamp = strtotime($str)) === -1) {
  3. echo "The string ($str) is bogus";
  4. } else {
  5. echo "$str == ". date('l dS of F Y h:i:s A',$timestamp);
  6. }
  7. ?>

这个效果和用mktime()是一样的。

希望以上的介绍与示例,对大家有所帮助。 有关php strtotime函数的用法,还可以参考: PHP strtotime函数详细介绍 PHP中strtotime函数用法举例 php中strtotime()与mktime() 的Y2K38漏洞 2038年问题 php时间戳函数 strtotime 应用实例 php中strtotime的函数效率

人气教程排行