http://stackoverflow.com/questions/6796866/php-date-yesterday
130
| date() itself is only for formatting, but it accepts a second parameter.
To keep it simple I just subtract 24 hours from the unix timestamp.
A modern oop-approach is using
DateTime
Or in your case (more readable/obvious)
(Because
DateInterval is negative here, we must add() it here)
See also:
DateTime::sub() and DateInterval | |||
78
| strtotime() , as in date("F j, Y", strtotime("yesterday")); | ||||
|
58
|
How easy :)
|
DateTime
-, or aDateInterval
-object (or both), which may be the case in an OOP-based application (e.g.$customer->expire->add(DateInterval::createFromDateString('+1 year')) // customer paid for one additional year
) Also note, thatDateInterval
understands ISO8601 for time intervals, butdate()
doesn't. At the end of course: Select the one you better fit your needs :) – KingCrunch Apr 12 '12 at 8:19DateInterval
. – KingCrunch Apr 25 '13 at 14:26