Strtotime steps that are quite useful in php

Source: Internet
Author: User
Tags echo date
In php, the strtotime Method & nbsp; often needs to calculate the date. for example, to calculate the date one month ago, the fastest way is to use strtotime, the strtotime method is quite useful in echostrtotime (now), n; echostrtotime (10September2000), n; echostrtoti php.
In PHP, it is often necessary to calculate the date. for example, to calculate the date a month ago, it is actually the fastest way.
Strtotime is used, and its functions are rich as follows:

Echo strtotime ("now"), "\ n"; echo strtotime ("10 September 2000"), "\ n"; echo strtotime ("+ 1 day "), "\ n"; echo strtotime ("+ 1 week"), "\ n"; echo strtotime ("+ 1 week 2 days 4 hours 2 seconds "), "\ n"; echo strtotime ("next Thursday"), "\ n"; echo strtotime ("last Monday"), "\ n ";

If we see no more than 1 day + 1 week, we can find the date after 1 day and 1 week,
If you want to calculate a month ago, you can:
Echo date ('Y-m-D', strtotime ('1 month ago '))

Therefore, you can determine whether a month ago
If strtotime ($ my_date) <strtotime ('1 month ago '))

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.