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")));
But, how do I find what was 5 days ago from any date, not just today?
For example: What was 5 days prior to 2008-12-02?
If your date is already a DateTime or DateTimeImmutable you can use the format method. $day_of_week = intval($date_time->format('w'));
The strtotime() function parses an English textual datetime into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT). Note: If the year is specified in a two-digit format, values between 0-69 are mapped to 2000-2069 and values between 70-100 are mapped to 1970-2000.
I think a readable way of doing that is:
$days_ago = date('Y-m-d', strtotime('-5 days', strtotime('2008-12-02')));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With