Summary of php time computing problems and php Problems
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 ")));}