PHP returns the start timestamp of the current year, month, and day, And the start timestamp of the next year, month, and day. The current Start Time

Source: Internet
Author: User

PHP returns the start timestamp of the current year, month, and day, And the start timestamp of the next year, month, and day. The current Start Time

1. timestamp of the current year

2. timestamp of the current month

3. Current day Timestamp

4. Start timestamp of next year

5. Start timestamp of next month

6. Start timestamp of tomorrow

7. Current Timestamp

Function Code:

/*** Obtain the timestamp * $ Ymd = Y * $ Ymd = m * $ Ymd = d * $ Ymd = NULL current timestamp * $ xia = true whether to remove start timestamp: remove the year start timestamp or next month start timestamp or tomorrow start timestamp */function getTime ($ Ymd = NULL, $ xia = false) {if ($ Ymd = 'y' & $ xia = true) {// return strtotime (date ('y ', time () + 1 ). '-01-01 00:00:00');} else if ($ Ymd = 'y') {// return strtotime (date ('y ', time ()). '-01-01 00:00:00');} else if ($ Ymd = 'M' & $ xia = true) {// remove a monthly start timestamp $ xiayue_nianfen = date ('y', time (); $ xiayue_yuefen = date ('M', time ()); if ($ xiayue_yuefen = 12) {$ xiayue_nianfen + = 1; // if the month is December, then the year of the next month + 1 $ xiayue_yuefen = 1; // if the month is December, then next month = January} else {$ xiayue_yuefen + = 1; // If the month is not December, + 1} return strtotime ($ xiayue_nianfen in the current month. '-'. $ xiayue_yuefen. '-01 00:00:00');} else if ($ Ymd = 'M') {// return strtotime (date ('Y-m ', time ()). '-01 00:00:00');} else if ($ Ymd = 'D' & $ xia = true) {// return strtotime (date ('Y-m-d', time ()). '00:00:00 ') + 86400;} else if ($ Ymd = 'D') {// return strtotime (date ('Y-m-d ', time ()). '00:00:00 ');} else {// get the current timestamp return time ();}}

Call code:

GetTime ('y'); // The timestamp of the current year getTime ('M'); // The timestamp of the current month getTime ('D '); // The current day's timestamp getTime ('y', true); // The next year's timestamp getTime ('M', true ); // next month's timestamp getTime ('D', true); // tomorrow's timestamp getTime (); // current Timestamp

 

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: info-contact@alibabacloud.com 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.