The day before yesterday to the interview is also the case, but I did not remember at that time. Remember MYSQL date_sub (now (), 'interval 1 day'); date ('Y / m / dh: i: s', mktime ( date ('h'), date ('i'), date ('s'), date ('m'), date ('d') + 1, date ('Y')));
-------------------------------------------------- ------------------------------
Get today's UNIXTIME
Then subtract one or two days from the number of UNIXTIME minus the formatted date.
-------------------------------------------------- ------------------------------
The following is quoted content:
<? php
date_default_timezone_set ('Asia / Shanghai');
#yesterday
echo date ("Y / m / dh: i: s", time () - 24 * 60 * 60);
echo "<br>";
# The day before yesterday
echo date ("Y / m / dh: i: s", time () - 2 * 24 * 60 * 60);
?>
-------------------------------------------------- ------------------------------
up
-------------------------------------------------- ------------------------------
There are many ways ah, I also introduce a kind of:
date ("Y / m / d H: i: s", strtotime ("1 days ago"));
date ("Y / m / d H: i: s", strtotime ("2 days ago"));
-------------------------------------------------- ------------------------------
date ("m"), date ("d") - 1, date ("Y")));
-------------------------------------------------- ------------------------------
Previously counted time is always annoying, huh, huh, learned, the following is the next week now time.
date_default_timezone_set ('Asia / Shanghai');
$ tmp = time () + 60 * 60 * 24 * 7;
print date ("m / d / YH: i: s", $ tmp);
-------------------------------------------------- ------------------------------
Add one:
$ time_yes = localtime (time () - 24 * 60 * 60, true);
$ time_b_yes = localtime (time () - 2 * 24 * 60 * 60, true);
$ yesterday = $ time_yes ['tm_mday'];
$ the_day_before_yes = $ time_b_yes ['tm_mday'];
-------------------------------------------------- ------------------------------
time () - 86400 yesterday
The following is quoted content:
<?
//yesterday
print date ('Ymd', strtotime ('- 1 day'));
//last week
print date ('Ymd', strtotime ('- 1 week'));
//last month
print date ('Ymd', strtotime ('- 1 month'));
//last year
print date ('Ymd', strtotime ('- 1 year'));
?>
-------------------------------------------------- ------------------------------
strtotime get a timestamp, then format it yourself.
strtotime ('yesterday');
strtotime ('- 2 day');