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