This article mainly introduces the related issues of php time computing, and summarizes and analyzes common php operation skills on time and date in the form of examples, which has some reference value, for more information about php time computing, see the examples in this article. 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 ")));}