PHP gets today, yesterday, tomorrow's date

Source: Internet
Author: User

PHP gets today, yesterday, tomorrow's date

How to get a timestamp, which is a problem that PHP programmers often encounter. Before the use of the time to go to Baidu, so has not been serious to understand.
Today's company program development needs, I am responsible for the development of a sign-in small function, due to the need to get consecutive check-in days, so must get yesterday's whether signed
To the situation, and then all of a sudden short-circuited, yesterday how to get? If you simply use a timestamp minus 24 hours, it's very
Not rigorous. In order to solve this problem, go to the Internet to find information, and finally the time stamp of the problem are understood, now share out, first paste code,
Then do a detailed answer.
<?php  echo "Today:". Date ("y-m-d"). " <br> ";       echo "Yesterday:" Date ("y-m-d", Strtotime ("1 day"), "<br>";       echo "Tomorrow:". Date ("Y-m-d", Strtotime ("+1 Day")). " <br> ";    echo "One week later:". Date ("Y-m-d", Strtotime ("+1 Week")). " <br> ";       echo "2 days a week four hours two seconds after:". Date ("Y-m-d g:h:s", Strtotime ("+1 Week 2 Day 4 hours 2 Seconds")). " <br> ";       echo "Next week Four:". Date ("Y-m-d", Strtotime ("next Thursday")). " <br> ";       echo "Previous Monday:". Date ("Y-m-d", Strtotime ("Last Monday")). " <br> ";       echo "One months ago:". Date ("Y-m-d", Strtotime ("Last month"). " <br> ";       echo "One months later:". Date ("Y-m-d", Strtotime ("+1 Month")). " <br> ";       echo "Ten years later:". Date ("Y-m-d", Strtotime ("+10 Year")). " <br> ";      ? >

PHP gets today, yesterday, tomorrow's date

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.