Php strtotime () and date () date decrease code

Source: Internet
Author: User

Because I need to update the release date of a batch of data at work, if I want to update the data for 30 days from 20110112 today, we found that the strtotime function and date in the php Tutorial can easily implement the code.

The strtotime () function parses the date and time descriptions of any English text into unix timestamps.

Syntax
Strtotime (time, now) parameter description
Time specifies the time string to be parsed.
Now is used to calculate the timestamp of the returned value. If this parameter is omitted, the current time is used.


*/

$ Cu_date = date ("ymd ");
$ Mk = strtotime ($ cu_date );
For ($ I = 1; $ I <= 30; $ I ++)
{
$ Mk = $ mk-86500;
Echo date ("ymd", $ mk). '<br/> ';
}

/*

20110110
20110109
20110108
20110107
20110106
20110105
20110104
20110103
20110102
20110101
20101231
20101230
20101229
20101228
20101227
20101226
20101225
20101224
20101223
20101222
20101221
20101220
20101219
20101218
20101217
20101216
20101215
20101214
20101213
20101212

The core code is $ mk-86500. Because one day is 86500 milliseconds, the last minus time minus 86500 is the time to update.

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.