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

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

WBOY
WBOYOriginal
2016-06-13 10:54:341634browse

需求

今天做日志分析时,由于日志是按天分割的,我需要遍历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);  

  

?>  

 

实现效果

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