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

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

WBOY
WBOYOriginal
2016-07-29 09:11:21888browse
/**
 * 获取当前时间信息数组
 * @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. .

Statement:
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
Previous article:PHP的学习--可变函数Next article:20151127网站构建