Home > Article > Backend Development > PHP gets yesterday's timestamp, current time information array, last week and last week's year, last month and last month's year
/** * 获取当前时间信息数组 * @params void * @return array */ function get_current_time_array() { $date = strtotime(date('Y-m-d')); //日期时间戳 $week = (int)date('W'); //本年第几周 $month = (int)date('n'); //月份 $year = (int)date('Y'); //年份 $time_array = array( 'date' => $date, 'week' => $week, 'month' => $month, 'year' => $year, ); } /** * 获取昨天时间戳 * @params void * @return int */ function get_prev_day() { return strtotime(date('Y-m-d', strtotime('last day')));rrree
The above introduces PHP to obtain yesterday's timestamp, current time information array, last week and last week's year, last month and last month's year, including the content. I hope it will be helpful to friends who are interested in PHP tutorials. .