Php obtains the start timestamp and end timestamp of today, yesterday, last week, and this month.-PHP source code

Source: Internet
Author: User
Php obtains the start and end timestamps of today, yesterday, last week, and this month.
// Php obtains the start and end timestamp of today. $ beginToday = mktime (0, 0, date ('M'), date ('D '), date ('Y'); $ endToday = mktime (0, 0, 0, date ('M'), date ('D') + 1, date ('Y ')) -1; echo "start timestamp today :". $ beginToday. '----'. date ('Y-m-d H: I: S', $ beginToday ).'
'; Echo "end time of today:". $ endToday.' ---- '. date ('Y-m-d H: I: S', $ endToday ).'
'; // Php obtains the start timestamp and end timestamp of Yesterday $ beginYesterday = mktime (, 0, date ('M'), date ('D')-1, date ('Y'); $ endYesterday = mktime (0, 0, 0, date ('M'), date ('D'), date ('Y ')) -1; echo "start timestamp yesterday :". $ beginYesterday. '----'. date ('Y-m-d H: I: S', $ beginYesterday ).'
'; Echo "yesterday's end timestamp:". $ endYesterday.' ---- '. date ('Y-m-d H: I: S', $ endYesterday ).'
'; // Php obtains the last week's start timestamp and end timestamp $ beginLastweek = mktime (0, 0, 0, date ('M'), date ('D ') -date ('w') + 1-7, date ('Y'); $ endLastweek = mktime (, 59, 59, date ('M '), date ('D')-date ('w') + 7-7, date ('Y'); echo "last week start timestamp :". $ beginLastweek. '----'. date ('Y-m-d H: I: S', $ beginLastweek ).'
'; Echo "last week end timestamp:". $ endLastweek.' ---- '. date ('Y-m-d H: I: S', $ endLastweek ).'
'; // Php obtains the start timestamp and end timestamp of this month $ beginThismonth = mktime (, 0, date ('M'), 1, date ('Y ')); $ endThismonth = mktime (, 59, 59, date ('M'), date ('t'), date ('Y'); echo "start timestamp of this month :". $ beginThismonth. '----'. date ('Y-m-d H: I: S', $ beginThismonth ).'
'; Echo "end of this month timestamp:". $ endThismonth.' ---- '. date ('Y-m-d H: I: S', $ endThismonth ).'
';

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.