Time computing, php: php time computing issues Summary: This example summarizes php time computing issues. Share it with you for your reference. The details are as follows: 1. php obtains the date three months ago & lt; php $ s_sdatedate (Y-m-d); current time $ moth_day90; month (converted to days) $ s_edatedate (Y-m-d, (strtotime ($ s _ this example summarizes the related issues of php time computing. We will share this with you for your reference. The details are as follows:
1. php obtains the date three months ago.
<? Php header ("content-Type: text/html; charset = utf-8");?> <? Php $ s_sdate = date ("Y-m-d"); // Current Time $ moth_day = 90; // month (converted to days) $ s_edate = date ("Y-m-d", (strtotime ($ s_sdate)-$ moth_day * 84600); echo $ moth_day. the date before ". $ s_edate;?>
2. 30 days after the calculation date
You can use strtotime PHP to provide a super simple way to complete the work of dozens of lines of code.
First convert a date to a UNIX timestamp
$ T = time (); // Current timestamp $ t = strtotime ("+ 30 days", $ t ); // 30 days later, the timestamp echo date ("Y-m-d", $ t); // format the date
3. convert the timestamp of 2 days... then subtract
$ T1 = strtotime ("2009-08-19"); $ t2 = strtotime ("2009-08-20"); $ t = $ t2-$ t1; // second echo (int) for days of difference) ($ t/86400)
4. determine whether it is this week
$ Date = "2008-12-08"; if (isCurrentWeeks ($ date) {echo $ date. "Is this week";} else {echo $ date. "Not this week";} function isCurrentWeeks ($ d) {return (date ("W", strtotime ($ d) = date ("W ", strtotime ("now ")));}