007-strtotime的时间处理

《令人困惑的strtotime》 http://www.laruence.com/2018/07/31/3207.html

PHP系统自动处理

>>> date('Y-m-d', strtotime('+1month', strtotime('2017-02-28')))
=> "2017-03-28"
>>> date('Y-m-d', strtotime('-1month', strtotime('2017-02-28')))
=> "2017-01-28"
>>> date('Y-m-d', strtotime('-1month', strtotime('2017-03-31')))
=> "2017-03-03"
>>> date('Y-m-d', strtotime('+1month', strtotime('2017-03-31')))
=> "2017-05-01"

自行设定格式日期:last day offirst day of

>>> date('Y-m-d', strtotime('last day of +1month', strtotime('2017-03-31')))
=> "2017-04-30"
>>> date('Y-m-d', strtotime('first day of +1month', strtotime('2017-03-31')))
=> "2017-04-01"
>>> date('Y-m-d', strtotime('first day of -1month', strtotime('2017-03-31')))
=> "2017-02-01"
>>> date('Y-m-d', strtotime('last day of -1month', strtotime('2017-03-31')))
=> "2017-02-28"
>>> date('Y-m-d', strtotime('last day of -1month', strtotime('2017-02-01')))
=> "2017-01-31"
>>> date('Y-m-d', strtotime('first day of -1month', strtotime('2017-02-01')))
=> "2017-01-01"
>>> date('Y-m-d', strtotime('first day of -1month', strtotime('2017-02-28')))
=> "2017-01-01"
>>> date('Y-m-d', strtotime('last day of -1month', strtotime('2017-02-28')))
=> "2017-01-31"
>>> date('Y-m-d', strtotime('last day of +1month', strtotime('2017-02-28')))
=> "2017-03-31"
>>> date('Y-m-d', strtotime('first day of +1month', strtotime('2017-02-28')))
=> "2017-03-01"

你可能感兴趣的:(007-strtotime的时间处理)