How to find out what the date was 5 days ago?

后端 未结 10 1647
一整个雨季
一整个雨季 2020-12-24 04:46

Well, the following returns what date was 5 days ago:

$days_ago = date(\'Y-m-d\', mktime(0, 0, 0, date(\"m\") , date(\"d\") - 5, date(\"Y\")));
相关标签:
10条回答
  • 2020-12-24 05:20

    simple way to find the same is

    $date = date("Y-m-d", strtotime('-5 days', strtotime('input_date')));
    
    0 讨论(0)
  • 2020-12-24 05:21

    General algorithms for date manipulation convert dates to and from Julian Day Numbers. Here is a link to a description of such algorithms, a description of the best algorithms currently known, and the mathematical proofs of each of them: http://web.archive.org/web/20140910060704/http://mysite.verizon.net/aesir_research/date/date0.htm

    0 讨论(0)
  • 2020-12-24 05:23

    I think a readable way of doing that is:

    $days_ago = date('Y-m-d', strtotime('-5 days', strtotime('2008-12-02')));
    
    0 讨论(0)
  • 2020-12-24 05:23

    find out what the date was 5 days ago from today in php

    $date = strtotime(date("Y-m-d", strtotime("-5 day")));
    

    find out what the date was n days ago from today in php

    $date = strtotime(date("Y-m-d", strtotime("-n day")));
    
    0 讨论(0)
提交回复
热议问题