<?php

header("content-type:text/html;charset=utf-8");


//PRC代指中国时间,添加后可以正确获取中国时间
date_default_timezone_set('PRC');

//获取当前电脑的时间
echo '现在的时间是:'.date('Y-m-d H:i:s');
echo '<br>';echo '<br>';

//获取昨天的现在时间(方法1)
echo '昨天的现在的时间是:'.date('Y-m-d H:i:s', strtotime('-1 day'));
echo '<br>';
//获取昨天的现在时间(方法2)
echo '昨天的现在的时间是:'.date('Y-m-d H:i:s', time()-86400);
echo '<br>';

//获取上一周的现在时间
echo '上一周的现在的时间是:'.date('Y-m-d H:i:s', strtotime('-1 week'));
echo '<br>';

//获取上周二的现在时间
echo '上周二的现在的时间是:'.date('Y-m-d', strtotime('last Tuesday -1 week')).date(' H:i:s');
echo '<br>';

//获取明天的现在时间(方法1)
echo '明天的现在的时间是:'.date('Y-m-d H:i:s', strtotime('+1 day'));
echo '<br>';
//获取明天的现在时间(方法2)
echo '明天的现在的时间是:'.date('Y-m-d H:i:s', time()+86400);
echo '<br>';

//获取下一周的现在时间
echo '下一周的现在的时间是:'.date('Y-m-d H:i:s', strtotime('+1 week'));
echo '<br>';

//获取下周一的现在时间
echo '下周一的现在的时间是:'.date('Y-m-d', strtotime('next Monday')).date(' H:i:s');
echo '<br>';

//显示本月的第一天的日期
echo '本月第一天是:'.date('Y-m-01');
echo '<br>';

//显示本月的最后一天的日期
echo '本月最后一天是:'.date('Y-m-t');
echo '<br>';

?>

 

相关文章:

  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-27
猜你喜欢
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2021-11-21
  • 2022-03-04
  • 2021-07-29
  • 2021-08-02
相关资源
相似解决方案