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.