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

PHP如何从 字符串中获取时间日期

发布时间:2023-02-04 11:11:28 所属栏目:PHP 来源:
导读:  echo strtotime("now"), "<br />";

  echo strtotime("10 September 2000"), "<br />";

  echo strtotime("+1 day"), "<br />";

  echo strtotime("+1 week"), &quo

  echo strtotime("now"), "<br />";
 
  echo strtotime("10 September 2000"), "<br />";
 
  echo strtotime("+1 day"), "<br />";
 
  echo strtotime("+1 week"), "<br />";
 
  echo strtotime("+1 week 2 days 4 hours 2 seconds"), "<br />";
 
  echo strtotime("next Thursday"), "<br />";
 
  echo strtotime("last Monday"), "<br />";
 
  ?>
 
  执行以上程序打印出来的结果类似:
  1572597225 968515200 1572683625 1573202025 1573389227 1573056000 1572192000
 
  日期的加减运算 有时我们需要在一个日期上加减一定的时间间隔。可以使用 strtotime() 来计算一些日期时间间隔。示例如下:
  <?php
 
  $start = 'last Monday';
 
  $interval = strtotime("$start + 4 days");
 
  echo "现在\$interval 表示上周的" . date('l',$interval);
 
  ?>
 
  执行以上程序的输出结果为:
  现在 $interval 表示上周的 Friday。
 

(编辑:草根网)

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

    推荐文章