Home  >  Article  >  Backend Development  >  PHP uses date format to output a specified range of time_PHP tutorial

PHP uses date format to output a specified range of time_PHP tutorial

WBOY
WBOYOriginal
2016-07-14 10:08:14981browse

need

When doing log analysis today, since the logs are divided by day, I need to traverse 30 days of logs. If I get an array suffix like 20130101-20130131, I wrote a small program to implement it. I will record it here. Mainly the application of date function and strtotime function
php implementation code
[php]
$stand = "2013-01-";
for ($i = 1; $i <= 31; $i ++) {
$time = strtotime($stand . $i);
$date[] = date("Ymd", $time);
}
print_r($date);
?>
Achieve results
PHP uses date format to output a specified range of time_PHP tutorial

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477789.htmlTechArticleWhen I need to do log analysis today, since the logs are divided by day, I need to traverse 30 days of logs. If To get an array suffix like 20130101-20130131, I wrote a small program to achieve it...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn