PHP Date Time calculation, reprint

Source: Internet
Author: User

PHP Get Today's Date

Date ("y-m-d");



PHP Get yesterday date

Date ("y-m-d", strtotime ("-1 Day"))



PHP Get tomorrow Date

Date ("y-m-d", strtotime ("+1 Day"))



PHP gets a week after date

Date ("y-m-d", strtotime ("+1 Week"))



PHP gets 2 days, four hours, two seconds, time a week.

Date ("y-m-d g:h:s", strtotime ("+1 Week 2 days 4 hours 2 Seconds"))



PHP Get next week 4th period

Date ("y-m-d", strtotime ("next Thursday"))



PHP get last week 1st period

Date ("y-m-d", strtotime ("last Monday"))



PHP gets one month ago date

Date ("y-m-d", strtotime ("last Month"))



PHP gets one months after date

Date ("y-m-d", strtotime ("+1 Month"))



PHP gets ten years later date

Date ("y-m-d", strtotime ("+10 Year"))



PHP get today start and end timestamp

Mktime (0,0,0,date (' m '), date (' d '), date (' Y '));

Mktime (0,0,0,date (' m '), date (' d ') +1,date (' Y '))-1;



PHP gets yesterday start time stamp

Mktime (0,0,0,date (' m '), date (' d ') -1,date (' Y '));

Mktime (0,0,0,date (' m '), date (' d '), date (' Y '))-1;



PHP gets last week time stamp

Mktime (0,0,0,date (' m '), date (' d ')-date (' w ') +1-7,date (' Y '));

Mktime (23,59,59,date (' m '), date (' d ')-date (' w ') +7-7,date (' Y '));



PHP gets this month's start time stamp

Mktime (0,0,0,date (' m '), 1,date (' Y '));

Mktime (23,59,59,date (' m '), date (' t '), date (' Y '));


This article is from the "php/[email protected]" blog, Be sure to keep this source http://liang3391.blog.51cto.com/178205/1841323

PHP Date Time calculation, reprint

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.