需求
今天做日志分析时,由于日志是按天分割的,我需要遍历30天的日志,如果获得类似20130101-20130131这样的数组后缀呢,写了个小程序实现了一下,这里记录一下,主要是date函数和strtotime函数的应用
php实现代码
[php]
立即学习“PHP免费学习笔记(深入)”;
$stand = "2013-01-";
for ($i = 1; $i
$time = strtotime($stand . $i);
$date[] = date("Ymd", $time);
}
print_r($date);
?>
实现效果
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号