Summary of php time computing related issues php computing execution time php one-day timestamp calculation remaining time of php computing

Source: Internet
Author: User
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 ")));}

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.