PHP uses the date and Strtotime functions to output a specified date method, datestrtotime_php tutorial

Source: Internet
Author: User

PHP uses the date and Strtotime functions to output a specified date method, Datestrtotime


This example describes how PHP uses date and strtotime functions to output a specified date. Share to everyone for your reference. The specific methods are analyzed as follows:

In PHP, the date and Strtotime functions are operations on dates, but in the generation above date and strtotime are not the same, one is the number date one is the Unix timestamp, but we can all generate the same date, the following two examples of functions.

PHP often uses the date function and the Strtotime function, these 2 functions are not unfamiliar to everyone, today and we share the use of skills.

strtotime-to parse the datetime description of any English text into a Unix timestamp
Copy the Code code as follows: Date_default_timezone_set (' Asia/shanghai ');
To calculate the time of yesterday, we used:
Date ("Ymd", Time ()-3600);
Generate yesterday's time
Date ("Ymd", Strtotime (' Yesterday '));
Date ("Ymd", Strtotime ('-1 day '));
Generate time the day before
Date ("Ymd", Strtotime (' Yesterday-1 Day '));
Date ("Ymd", Strtotime ('-2 day '));
Time after 3 days of generation
Date ("Ymd", Strtotime (' +3 Day '));
Generated one months ago
Date ("Ymd", Strtotime ('-1 month '));
Generate the time of the last day of next month
Date ("Ymd", Strtotime (' Last day of next month '));
Monday of next week
Date ("Ymd", Strtotime (' next Monday '));

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/911908.html www.bkjia.com true http://www.bkjia.com/PHPjc/911908.html techarticle PHP uses the date and Strtotime functions to output a method of specifying a date, Datestrtotime This example describes how PHP uses date and strtotime functions to output a specified date. Share for everyone to join us ...

  • Related Article

    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.