去评论
dz插件网

dz插件php得到今天/上周/本周/上月/本月/本季度/上季度起止...

admin
2021/01/17 17:03:18
dz插件php得到今天/上周/本周/上月/本月/本季度/上季度起止时间:
插件做排行或计划任务时可能有用,记录一下:

  1. date_default_timezone_set('PRC');
  2. date("Y-m-d H:i:s", strtotime(" +2 year"));
  3. date("Y-m-d H:i:s", strtotime(" +2 month"));
  4. date("Y-m-d H:i:s", strtotime(" +2 week"));
  5. date("Y-m-d H:i:s", strtotime(" +2 day"));
  6. date("Y-m-d H:i:s", strtotime(" +2 hour"));
  7. date("Y-m-d H:i:s", strtotime(" +2 minute"));
  8. date("Y-m-d H:i:s", strtotime(" +2 second"));
  9. echo date("Ymd",strtotime("now")), "\n";
  10. echo date("Ymd",strtotime("-1 week Monday")), "\n";
  11. echo date("Ymd",strtotime("-1 week Sunday")), "\n";
  12. echo date("Ymd",strtotime("+0 week Monday")), "\n";
  13. echo date("Ymd",strtotime("+0 week Sunday")), "\n";
  14. echo "*********第几个月:";
  15. echo date('n');
  16. echo "*********本周周几:";
  17. echo date("w");
  18. echo "*********本月天数:";
  19. echo date("t");
  20. echo "*********";
  21. echo '<br>今天:<br>';
  22. echo date("Y-m-d H:i:s",mktime(0, 0, 0, date("m"), date("d"), date("Y"))),"\n";
  23. echo date("Y-m-d H:i:s",mktime(23,59,59, date("m"), date("d"), date("Y"))),"\n";
  24. echo '<br>上周:<br>';
  25. echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1-7,date("Y"))),"\n";
  26. echo date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7-7,date("Y"))),"\n";
  27. echo '<br>本周:<br>';
  28. echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"))),"\n";
  29. echo date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"))),"\n";
  30. echo '<br>上月:<br>';
  31. echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m")-1,1,date("Y"))),"\n";
  32. echo date("Y-m-d H:i:s",mktime(23,59,59,date("m") ,0,date("Y"))),"\n";
  33. echo '<br>本月:<br>';
  34. echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),1,date("Y"))),"\n";
  35. echo date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("t"),date("Y"))),"\n";
  36. $season = ceil((date('n'))/3);//当月是第几季度
  37. echo '<br>本季度:<br>';
  38. echo date('Y-m-d H:i:s', mktime(0, 0, 0,$season*3-3+1,1,date('Y'))),"\n";
  39. echo date('Y-m-d H:i:s', mktime(23,59,59,$season*3,date('t',mktime(0, 0 , 0,$season*3,1,date("Y"))),date('Y'))),"\n";
  40. $season = ceil((date('n'))/3)-1;//上季度是第几季度
  41. echo '<br>上季度:<br>';
  42. echo date('Y-m-d H:i:s', mktime(0, 0, 0,$season*3-3+1,1,date('Y'))),"\n";
  43. echo date('Y-m-d H:i:s', mktime(23,59,59,$season*3,date('t',mktime(0, 0 , 0,$season*3,1,date("Y"))),date('Y'))),"\n";