Home > Backend Development > PHP Tutorial > PHP gets yesterday's timestamp, current time information array, last week and last week's year, last month and last month's year

PHP gets yesterday's timestamp, current time information array, last week and last week's year, last month and last month's year

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 09:11:21
Original
926 people have browsed it
/**
 * 获取当前时间信息数组
 * @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')));
Copy after login
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. .

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template