PHP get today tomorrow time yesterday timestamp of the N method Summary, PHP get today, yesterday, the time of tomorrow's method summarized as follows:
Header ("Content-type:text/html;charset=utf-8");
//--------------------------------------------------------------------------------
Date_default_timezone_set (' Asia/shanghai ');
Echo '
';
Echo ' Today: ', date (' y-m-d '), '
';
Echo ' Yesterday: ', date (' y-m-d ', Strtotime ('-1 day ')), '
';
Echo ' Yesterday: ', date (' y-m-d ', Strtotime (' Yesterday ')), '
';
Echo ' Tomorrow: ', date (' y-m-d ', Strtotime (' +1 Day ')), '
';
Echo ' One week later: ', date (' y-m-d ', Strtotime (' +1 Week ')), '
';
Echo ' 2 days a week four hours two seconds after: ', date (' y-m-d g:h:s ', Strtotime (' +1 Week 2 days 4 hours 2 seconds ')), '
';
Echo ' next week four: ', date (' y-m-d ', Strtotime (' next Thursday ')), '
';
Echo ' previous Monday: ', date (' y-m-d ', Strtotime (' last Monday ')), '
';
echo ' One months ago: ', date (' y-m-d ', Strtotime (' last month '), '
';
Echo ' One months later: ', date (' y-m-d ', Strtotime (' +1 month ')), '
';
Echo ' Ten years later: ', date (' y-m-d ', Strtotime (' +10 Year ')), '
';
Echo ' Yesterday: ', Date (' y/m/d h:i:s ', Strtotime (' 1 days ago ')), '
';
Echo ' The day before yesterday: ', Date (' y/m/d h:i:s ', Strtotime (' 2 days ago ')), '
';
$time _yes=localtime (Time () -24*60*60, true);
$time _b_yes=localtime (Time () -2*24*60*60, true);
Echo 'LocalTime (Time () -24*60*60, true): ';p rint_r ($time _yes); Echo '
';
Echo 'LocalTime (Time () -2*24*60*60, true): ';p rint_r ($time _b_yes); Echo '
';
Echo ' Yesterday: ', Date (' y/m/d h:i:s ', Mktime (' 0,0,0,date (' m '), date (' d ') -1,date (' Y ')), '
';
Echo ' Tomorrow: ', date (' y/m/d h:i:s ', mktime (date (' H '), date (' I '), date (' s '), date (' m '), date (' d ') +1, date (' Y ')), '
';
First get today's unixtime, then subtract a day or two days of the number of seconds, the reduced unixtime format into a date.
Echo ' Yesterday: ', Date (' y/m/d h:i:s ', Time () -24*60*60), '
';
Echo ' The day before yesterday: ', Date (' y/m/d h:i:s ', Time () -2*24*60*60), '
';
//--------------------------------------------------------------------------------
The function of the Strtotime () function is to parse the datetime description into the unix timestamp int strtotime (string time [, int now]) This function expects to accept a string containing the U.S. English date format and attempt to parse it into a Unix timestamp (since J Anuary 1 1970 00:00:00 GMT), whose value is relative to the time given by the now parameter, if this parameter is not provided, the current time of the system.
LocalTime () Gets the local time array localtime ([int $timestamp [, bool $is _associative])) the localtime () function returns an array whose structure and the C function call return exactly the same.
The first parameter of LocalTime () is the timestamp and, if not given, the current time returned from a time ().
The second parameter is is_associative, which returns an ordinary numeric index array if set to false or not provided.
If this argument is set to TRUE then the localtime () function returns an associative array containing all the different cells returned by the LocalTime function call from C.
The different key names in the associative array are:
"Tm_sec"-Number of seconds
"Tm_min"-Number of minutes
"Tm_hour"-hours
"Tm_mday"-the day of the month
"Tm_mon"-the month ordinal of a year, starting from 0
"Tm_year"-year, starting from 1900
"Tm_wday"-the day of the week
"Tm_yday"-the day ordinal of a year
"TM_ISDST"-Daylight saving time is currently in effect Note: The month from 0 (January) to 11 (December), the number of weeks from 0 (Sunday) to 6 (Saturday).