: This article mainly introduces PHP's collection of yesterday's timestamp, current time information array, last week and last week's year, last month and last month's year, if you are interested in the PHP Tutorial, refer.
/*** Get the current time information array * @ params void * @ return array */function get_current_time_array () {$ date = strtotime (date ('Y-m-D'); // date timestamp $ week = (int) date ('w '); // week of the current year $ month = (int) date ('N'); // month $ year = (int) date ('Y '); // year $ time_array = array ('date' => $ date, 'week' => $ week, 'month' => $ month, 'year' => $ year,);}/*** get yesterday's timestamp * @ params void * @ return int */function get_prev_day () {return strtotime (date ('Y-m-D', strtotime ('last day ')));
// Or return strtotime ("-1 day", date ("Y-m-d "));} /*** obtain the year of last week and last week * @ params void * @ return array */function get_prev_week () {return array ('Week '=> (int) date ('W', strtotime ('last week'), 'year' => (int) date ('Y ', strtotime ('last week'),);}/*** get the year of the previous month and the previous month * @ params void * @ return array */function get_prev_month () {return array ('month' => (int) date ('N', strtotime ('last month'), 'year' => (int) date ('Y', strtotime ('last month ')),);}
The above describes how to obtain the yesterday's timestamp by PHP, the current time information array, the year of last week and last week, and the year of last month, if you are interested in PHP tutorials.