Home > php教程 > php手册 > php用date格式化输出指定范围的时间

php用date格式化输出指定范围的时间

WBOY
Release: 2016-06-13 10:54:34
Original
1643 people have browsed it

需求

今天做日志分析时,由于日志是按天分割的,我需要遍历30天的日志,如果获得类似20130101-20130131这样的数组后缀呢,写了个小程序实现了一下,这里记录一下,主要是date函数和strtotime函数的应用

 

php实现代码

[php]  

 

$stand = "2013-01-";  

  

for ($i = 1; $i

    $time = strtotime($stand . $i);  

    $date[] = date("Ymd", $time);  

}  

  

print_r($date);  

  

?>  

 

实现效果

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template