首頁 > 後端開發 > php教程 > php日期處理程式碼

php日期處理程式碼

WBOY
發布: 2016-07-25 08:42:26
原創
927 人瀏覽過
  1. echo "
    ";
  2. echo date("Y-m-d",strtotime("now")), "n";
  3. echo "
    ";
  4. echo date("Y-m-d",strtotime("-1 week Monday")), "n";
  5. echo "
    ";
  6. echo date("Y-m-d",strtotime("-1 week Sunday")), "n";
  7. echo "
    ";
  8. echo date("Y-m-d",strtotime(" 0 week Monday")), "n";
  9. echo "
    ";
  10. echo date("Y-m-d",strtotime(" 0 week Sunday")), "n";
  11. echo "
    ";
  12. echo "*********第几个月:";
  13. echo date('n');
  14. echo "
    ";
  15. echo "*********本周周几:";
  16. echo date("w");
  17. echo "
    ";
  18. echo "*********本月天数:";
  19. echo date("t");
  20. echo "
    ";
  21. echo '
    上周:
    ';
  22. echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w") 1-7,date("Y"))),"n";
  23. echo date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w") 7-7,date("Y"))),"n";
  24. echo "
    ";
  25. echo '
    本周:
    ';
  26. echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),date("d")-date("w") 1,date("Y"))),"n";
  27. echo date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-date("w") 7,date("Y"))),"n";
  28. echo "
    ";
  29. echo '
    上上月:
    ';
  30. echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m")-2,1,date("Y"))),"n";
  31. echo date("Y-m-d H:i:s",mktime(23,59,59,date("m")-1,0,date("Y"))),"n";
  32. echo "
    ";
  33. echo '
    上月:
    ';
  34. echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m")-1,1,date("Y"))),"n";
  35. echo date("Y-m-d H:i:s",mktime(23,59,59,date("m") ,0,date("Y"))),"n";
  36. echo "
    ";
  37. echo '
    本月:
    ';
  38. echo date("Y-m-d H:i:s",mktime(0, 0 , 0,date("m"),1,date("Y"))),"n";
  39. echo date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("t"),date("Y"))),"n";
  40. echo "
    ";
  41. echo "
    ";
  42. $season = ceil((date('n'))/3)-2;//上季度是第几季度
  43. echo '
    上上季度:
    ';
  44. echo date('Y-m-d H:i:s', mktime(0, 0, 0,$season*3-3 1,1,date('Y'))),"n";
  45. 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";
  46. echo "
    ";
  47. echo "
    ";
  48. $season = ceil((date('n'))/3)-1;//上季度是第几季度
  49. echo '
    上季度:
    ';
  50. echo date('Y-m-d H:i:s', mktime(0, 0, 0,$season*3-3 1,1,date('Y'))),"n";
  51. 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";
  52. echo "
    ";
  53. echo $season = ceil((date('n'))/3);//当月是第几季度
  54. echo '
    本季度:
    ';
  55. echo date('Y-m-d H:i:s', mktime(0, 0, 0,$season*3-3 1,1,date('Y'))),"n";
  56. 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";
  57. $season = ceil((date('n'))/3) 1;//当月是第几季度
  58. echo '
    下季度:
    ';
  59. echo date('Y-m-d H:i:s', mktime(0, 0, 0,$season*3-3 1,1,date('Y'))),"n";
  60. 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";
  61. echo "
    ";
  62. ?>
复制代码

php


相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板