It was the same thing the day before yesterday, but I couldn't remember. Just remember that date_sub (now (), ' Interval 1 days ') in MySQL;d ate (' y/m/d h:i:s ', mktime (' h '), date (' I ') , date (' s '), date (' m '), date (' d ') +1, date (' Y '));
--------------------------------------------------------------------------------
Get today's unixtime first.
Then subtract the number of seconds in a day or two days
Format the reduced unixtime as a date.
--------------------------------------------------------------------------------
Code:[copy to Clipboard] Date_default_timezone_set (' Asia/shanghai ');
#昨天
echo Date ("Y/m/d h:i:s", Time () -24*60*60);
echo "
";
#前天
echo Date ("Y/m/d h:i:s", Time () -2*24*60*60);
?>
--------------------------------------------------------------------------------
Up
--------------------------------------------------------------------------------
There are many ways to do this, I also introduce one kind of bar:
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"));
--------------------------------------------------------------------------------
Before the time is always very annoying, hehe, learning, the following is the time of next week now.
Date_default_timezone_set (' Asia/shanghai ');
$tmp = time () +60*60*24*7;
Print date ("m/d/y h:i:s", $tmp);
--------------------------------------------------------------------------------
Add one more:
$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
--------------------------------------------------------------------------------
A master like the cloud
--------------------------------------------------------------------------------
QUOTE:
Originally Posted by hutule110 on 2007-3-22 09:51
Date ("Y/m/d h:i:s", Mktime (0,0,0,date ("M"), Date ("D") -1,date ("Y"));
Oh, this is 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:
Originally Posted by hutule110 on 2007-3-22 09:51
Date ("Y/m/d h:i:s", Mktime (0,0,0,date ("M"), Date ("D") -1,date ("Y"));
Call the function more times
--------------------------------------------------------------------------------
Strtotime get a timestamp and then you format it yourself.
Strtotime (' Yesterday ');
Strtotime ('-2 day ');
http://www.bkjia.com/PHPjc/318458.html www.bkjia.com true http://www.bkjia.com/PHPjc/318458.html techarticle It was the same thing the day before yesterday, but I couldn't remember it. Date_sub (now (), ' Interval1day ') in MySQL;d ate (' y/m/dh:i:s ', mktime (date (' H '), date ( ' I '), date (' s '), date ...