美文网首页
007-strtotime的时间处理

007-strtotime的时间处理

作者: 霄峰 | 来源:发表于2019-05-08 10:19 被阅读0次

    《令人困惑的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的时间处理

          本文链接:https://www.haomeiwen.com/subject/gnluwftx.html