Php obtains the timestamp of today, tomorrow, and yesterday.

Source: Internet
Author: User
Tags echo date
Php get time today tomorrow yesterday timestamp 2011-06-309: 46 & lt ;? Phpecho today:. date (Y-m-d). & lt; br & gt ;;????? Echo yesterday:. date (Y-m-d, strtotime (-1day), & lt; br & gt ;;????? Echo tomorrow: php get time today tomorrow yesterday timestamp

Php obtains the timestamp of today, tomorrow, and yesterday.

Echo "today:". date ("Y-m-d ")."
";?????
Echo "yesterday:". date ("Y-m-d", strtotime ("-1 day ")),"
";?????
Echo "tomorrow:". date ("Y-m-d", strtotime ("+ 1 day "))."
";??

Echo "one week later:". date ("Y-m-d", strtotime ("+ 1 week "))."
";?????
Echo "one week, two days, four hours, two seconds later :". date ("Y-m-d G: H: s", strtotime ("+ 1 week 2 days 4 hours 2 seconds "))."
";?????
Echo "next Thursday:". date ("Y-m-d", strtotime ("next Thursday "))."
";?????
Echo "last Monday:". date ("Y-m-d", strtotime ("last Monday "))."
";?????
Echo "a month ago:". date ("Y-m-d", strtotime ("last month "))."
";?????
Echo "one month later:". date ("Y-m-d", strtotime ("+ 1 month "))."
";?????
Echo "Ten years later:". date ("Y-m-d", strtotime ("+ 10 year "))."
";????

The strtotime () function resolves the description of a date and time to a Unix timestamp.

Int?Strtotime? (String time [, int now])

?>

This function is expected to accept a string that contains a date format in American English and try to parse it into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT). its value is relative? Now? The time specified by the parameter. If this parameter is not provided, the current system time is used.

-------------------------------

?

Get the code for the day before yesterday and the day before yesterday in PHP.
This was also the case when I went to the interview the day before yesterday, but I couldn't remember it. remember the date_sub (now (), 'interval 1 DAY') in MYSQL; date ('Y/m/d h: I: S ', mktime (date ('h'), date ('I'), date ('s'), date ('M'), date ('D') + 1, date ('Y ')));

--------------------------------------------?
First, get today's UNIXTIME?
Then subtract the number of seconds from one or two days?
Format the reduced UNIXTIME to a date .?
--------------------------------------------

Reference content is as follows:
Date_default_timezone_set ('Asia/Shanghai ');?
# Yesterday?
Echo date ("Y/m/d h: I: s", time ()-24*60*60 );?
Echo"
";?
# The day before yesterday?
Echo date ("Y/m/d h: I: s", time ()-2*24*60*60 );?
?>?

--------------------------------------------?
Up?
--------------------------------------------?
There are many methods. I will also introduce one :?
Date ("Y/m/d H: I: s", strtotime ("1 days ago "));?
Date ("Y/m/d H: I: s", strtotime ("2 days ago "));?
--------------------------------------------?
Date ("Y/m/d H: I: s", mktime (0, 0, 0, date ("m"), date ("d")-1, date ("Y ")));?
--------------------------------------------?
In the past, the computing time was always annoying. after learning it, the following is the current time of the next week .?
Date_default_timezone_set ('Asia/Shanghai ');?
$ Tmp = time () + 60*60*24*7 ;?
Print date ("m/d/y h: I: s", $ tmp );?
--------------------------------------------?
Add :?
$ Time_yes = localtime (time ()-24*60*60, true );?
$ Time_ B _yes = localtime (time ()-2*24*60*60, true );?
$ Yesterday = $ time_yes ['TM _ mday'];?
$ The_day_before_yes = $ time_ B _yes ['TM _ mday'];?
--------------------------------------------?
Time ()-86400 yesterday's

Reference content is as follows:

// Yesterday?
Print date ('Y-m-D', strtotime ('-1 DAY '));?
// Last week?
Print date ('Y-m-D', strtotime ('-1 week '));?
// Last month?
Print date ('Y-m-D', strtotime ('-1 month '));?
// Last year?
Print date ('Y-m-D', strtotime ('-1 year '));?
?>


--------------------------------------------

Strtotime gets a timestamp and you can format it yourself .?
Strtotime ('Yesterday ');?
Strtotime ('-2 Day ');

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.