This was also the case when I went to the interview the day before yesterday, but I couldn't remember it. remember the date_sub (now (), 'interval 1 Day') in MYSQL; date ('y/m/d h: I: s ', mktime (date ('H'), date ('I'), date ('s'), date ('M'), date ('D') + 1, date ('y ')));
--------------------------------------------------------------------------------
First obtain the UNIXTIME of today
Then subtract the number of seconds from one or two days.
Format the reduced UNIXTIME to a date.
--------------------------------------------------------------------------------
CODE: [Copy to clipboard] <? Php
Date_default_timezone_set ('Asia/Shanghai ');
# Yesterday
Echo date ("Y/m/d h: I: s", time ()-24*60*60 );
Echo "<br> ";
# The day before yesterday
Echo date ("Y/m/d h: I: s", time ()-2*24*60*60 );
?>
--------------------------------------------------------------------------------
Up
--------------------------------------------------------------------------------
There are many methods. I will also introduce one:
Date ("Y/m/d H: I: s", strtotime ("1 days ago "));
Date ("Y/m/d H: I: s", strtotime ("2 days ago "));
--------------------------------------------------------------------------------
Date ("Y/m/d H: I: s", mktime (0, 0, 0, date ("m"), date ("d")-1, date ("Y ")));
--------------------------------------------------------------------------------
In the past, computing time was always annoying. After learning it, the following is the current time of the next week.
Date_default_timezone_set ('Asia/Shanghai ');
$ Tmp = time () + 60*60*24*7;
Print date ("m/d/y h: I: s", $ tmp );
--------------------------------------------------------------------------------
Add:
$ 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's
--------------------------------------------------------------------------------
Experts like Yunna
--------------------------------------------------------------------------------
QUOTE:
Original Post published by huule110
Date ("Y/m/d H: I: s", mktime (0, 0, 0, date ("m"), date ("d")-1, date ("Y ")));
That's good!
--------------------------------------------------------------------------------
<?
// Yesterday
Print date ('Y-m-d', strtotime ('-1 Day '));
// Last week
Print date ('Y-m-d', strtotime ('-1 week '));
// Last month
Print date ('Y-m-d', strtotime ('-1 month '));
// Last year
Print date ('Y-m-d', strtotime ('-1 year '));
?>
--------------------------------------------------------------------------------
QUOTE:
Original Post published by huule110
Date ("Y/m/d H: I: s", mktime (0, 0, 0, date ("m"), date ("d")-1, date ("Y ")));
More calls to Functions
--------------------------------------------------------------------------------
Strtotime gets a timestamp and you can format it yourself.
Strtotime ('yesterday ');
Strtotime ('-2 Day ');