PHP time stamp common conversions

Source: Internet
Author: User

1 //set China time zone2Date_default_timezone_set (' PRC ');3 //today's time to rub4 $today _start=Strtotime(Date(' y-m-d ', Time()).‘ 0:0:0 ');5 $today _end=Strtotime(Date(' y-m-d ', Time()).‘ 23:59:59 ');6 //the time stamp of yesterday7 $yesterday _start=Strtotime('-1 day '. ') 0:0:0 ');8 $yesterday _end=Strtotime('-1 day '. ') 23:59:59 ');9 //View last month's dateTen $first _day_of_month=Date(' Y-m ', Time()).‘ -01 00:00:01 '; One $t=Strtotime($first _day_of_month);  A Date(' Y-m ',$t); - Date(' Y-m ',Strtotime('-1 month ',$t)); - Date(' Y-m ',Strtotime('-2 month ',$t)); the  - //Get time stamp - method One: - $yesterday _s=Mktime(0,0,0,Date(' m '),Date(' d ')-1,Date(' Y '));//the time of yesterday started rubbing + $yesterday _e=Mktime(23,59,59,Date(' m '),Date(' d ')-1,Date(' Y '));//the time of yesterday's end rubs -  + $tenday _s=Mktime(0,0,0,Date(' m '),Date(' d ')-10,Date(' Y '));//timestamp started 10 days ago A $tenday _e=Mktime(23,59,59,Date(' m '),Date(' d ')-10,Date(' Y '));//timestamp ended 10 days ago at      - //Method two: - $yesterday _s=Strtotime(Date("Y-m-d",Strtotime(" -10 Day"). ' 0:0:0 ');//timestamp started 10 days ago - $yesterday _e=Strtotime(Date("Y-m-d",Strtotime(" -10 Day"). ' 23:59:59 ');//timestamp ended 10 days ago -      - //Method Three: in $day=$_request[' Day '];//date required for statistics - $time _s=Strtotime($day.‘ 0:0:0 '); to $time _e=Strtotime($day.‘ 23:59:59 '); +  - //Get the timestamp for this Monday the Strtotime(Date("Y-m-d",Strtotime("-1 week Monday"))); *  $ //get today start timestamp and end timestampPanax Notoginseng $beginToday=Mktime(0,0,0,Date(' m '),Date(' d '),Date(' Y '));  - $endToday=Mktime(0,0,0,Date(' m '),Date(' d ') +1,Date(' Y ')) -1;  the  + //get yesterday start timestamp and end timestamp A $beginYesterday=Mktime(0,0,0,Date(' m '),Date(' d ')-1,Date(' Y '));  the $endYesterday=Mktime(0,0,0,Date(' m '),Date(' d '),Date(' Y ')) -1;  +  - //get the start timestamp and end timestamp for the week $ $beginThisweek=Mktime(0,0,0,Date(' m '),Date(' d ')-Date(' W ') +1,Date(' Y ')); $ $endThisweek= Time();  -  - //get last week start timestamp and end timestamp the $beginLastweek=Mktime(0,0,0,Date(' m '),Date(' d ')-Date(' W ') +1-7,Date(' Y '));  - $endLastweek=Mktime(23,59,59,Date(' m '),Date(' d ')-Date(' W ') +7-7,Date(' Y ')); Wuyi  the //get this month start timestamp and end timestamp - $beginThismonth=Mktime(0,0,0,Date(' m '), 1,Date(' Y ')); Wu $endThismonth=Mktime(23,59,59,Date(' m '),Date(' t '),Date(' Y ')); -  About  //last month's start time: $ $begin _time=Strtotime(Date(' y-m-01 00:00:00 ',Strtotime('-1 month '))));  - $end _time=Strtotime(Date("Y-m-d 23:59:59",Strtotime(-Date(' d '). ' Day)));  -  - $begin _year=Strtotime(Date("Y", Time())." -1 "." -1 ");//starting this year A $end _year=Strtotime(Date("Y", Time())." -12 "." -31 ");//End of year +  the //Current time to the next morning time stamp of difference - $time= (Strtotime(Date(' y-m-d ')) +3600*24)- Time() ;

PHP time stamp common conversions

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.