分享学习心得,记录学习笔记
文章:84   访问:526036
今天是:
2025年09月09日 星期二


strtotime():将任何字符串的日期时间描述解析为 Unix 时间戳

  1. $date = array(
  2. '当前'=>'2019-07-09',
  3. '上一年'=>date( 'Y-m-d', strtotime('2019-07-09 -1 year') ),
  4. '上一月'=>date( 'Y-m-d', strtotime('2019-07-09 -1 month') ),
  5. '上一周'=>date( 'Y-m-d', strtotime('2019-07-09 -1 week') ),
  6. '上一日'=>date( 'Y-m-d', strtotime('2019-07-09 -1 day') ),
  7. '下一日'=>date( 'Y-m-d', strtotime('2019-07-09 +1 day') ),
  8. '下一周'=>date( 'Y-m-d', strtotime('2019-07-09 +1 week') ),
  9. '下一月'=>date( 'Y-m-d', strtotime('2019-07-09 +1 month') ),
  10. '下一年'=>date( 'Y-m-d', strtotime('2019-07-09 +1 year') ),
  11. );

输出

  1. Array
  2. (
  3. [当前] => 2019-07-09
  4. [上一年] => 2018-07-09
  5. [上一月] => 2019-06-09
  6. [上一周] => 2019-07-02
  7. [上一日] => 2019-07-08
  8. [下一日] => 2019-07-10
  9. [下一周] => 2019-07-16
  10. [下一月] => 2019-08-09
  11. [下一年] => 2020-07-09
  12. )


0人点赞

友情链接 doywb

2018-2025 Copyright© 米灵尔 浮叶蓝空 豫ICP备15007436号-1

豫公网安备 41152302000146号