Format time stamp, Time plus day

Source: Internet
Author: User
Tags echo date

$ceshi = "1417247764"; Time stamp format

First type:

$ceshi +86400;//The time stamp based on one day (i.e. 60*60*24)

The second type: $firstdaystr =date ("y-m-d h:i:s", $ceshi); Format timestamp, turn to normal format 2014-12-18

$end _time=strtotime ($firstdaystr. "+24 hours"); Add 24 hours to your time, just one more day. And is the time stamp format

$end _time=date ("y-m-d h:i", Strtotime ($firstdaystr. "+24 Hours")); Time plus one day, time to normal format


Some examples:

Date (' y-m-d h:i:s ', Strtotime (' +1 Day '));

Date (' y-m-d h:i:s ', Strtotime ("+1 day +1 hour +1 minute");

You can modify parameter 1 for any desired number of days  can also be changed to year (years), month (month), hour (hours), minute (minutes), second (SEC)
$tomorrow  = Date ("y-m-d", Mktime (0,0,0,date ("M")  , Date ("D") +1,date ("Y"));

<?php
Echo (Strtotime ("Now"));
Echo (Strtotime ("3 October)");
Echo (Strtotime ("+5 hours"));
Echo (Strtotime ("+1 Week"));
Echo (Strtotime ("+1 Week 3 days 7 hours 5 Seconds"));
Echo (Strtotime ("Next Monday"));
Echo (Strtotime ("Last Sunday"));
? >

First, the PHP timestamp function gets the UNIX timestamp strtotime ("2009-1-22″" example) of the specified date as follows:

Echo strtotime ("2009-1-22″") Result: 1232553600

Note: Return January 22, 2009 0:0 0 seconds time stamp

Second, the PHP timestamp function gets the English text date time example as follows:

Easy to compare, using date to convert the timestamp to the system time with the specified timestamp

(1) Print tomorrow at this time the timestamp strtotime ("+1 Day")

Current Time: Echo Date ("Y-m-d h:i:s", Time ()) Result: 2009-01-22 09:40:25

Specified time: echo date ("Y-m-d h:i:s", Strtotime ("+1 Day") Results: 2009-01-23 09:40:25

(2) Print the timestamp strtotime ("-1 day") at this time yesterday

Current Time: Echo Date ("Y-m-d h:i:s", Time ()) Result: 2009-01-22 09:40:25

Specified time: echo date ("Y-m-d h:i:s", Strtotime ("1 day")) Results: 2009-01-21 09:40:25

(3) Print the timestamp strtotime ("+1 Week") at this time next week

Current Time: Echo Date ("Y-m-d h:i:s", Time ()) Result: 2009-01-22 09:40:25

Specified time: echo date ("Y-m-d h:i:s", Strtotime ("+1 Week") Results: 2009-01-29 09:40:25

(4) Print the timestamp strtotime ("-1 week") at this time last week

Current Time: Echo Date ("Y-m-d h:i:s", Time ()) Result: 2009-01-22 09:40:25

Specified time: echo date ("Y-m-d h:i:s", Strtotime ("1 week")) Results: 2009-01-15 09:40:25

(5) Print a timestamp strtotime ("next Thursday") that specifies the next day of the week

Current Time: Echo Date ("Y-m-d h:i:s", Time ()) Result: 2009-01-22 09:40:25

Specified time: echo date ("Y-m-d h:i:s", Strtotime ("next Thursday") Results: 2009-01-29 00:00:00

(6) Print a timestamp strtotime ("last Thursday") that specifies the previous week

Current Time: Echo Date ("Y-m-d h:i:s", Time ()) Result: 2009-01-22 09:40:25

Specified time: echo date ("Y-m-d h:i:s", Strtotime ("last Thursday") Results: 2009-01-15 00:00:00

The above PHP Timestamp function example shows that strtotime can resolve the date-time description of any English text to a Unix timestamp, and we combine the mktime () or date () format date time to get the specified timestamp to achieve the required date time.

Example:

<?php/*************************************************************************** * * Copyright (c) Baidu.c OM, Inc. All Rights Reserved * $Id $ * **************************************************************************//timestamp Transfer date $date _time_array = getdate (1297845628); 1311177600 1316865566 $hours = $date _time_array ["hours"]; $minutes = $date _time_array ["Minutes"]; $seconds = $date _time_array ["seconds"];

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.