PHP obtains yesterday's timestamp, an array of current time information, last week and last week's year, last month and last month's year

Source: Internet
Author: User
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.