时间:2021-07-01 10:21:17 帮助过:2人阅读
今天做日志分析时,由于日志是按天分割的,我需要遍历30天的日志,如果获得类似20130101-20130131这样的数组后缀呢,写了个小程序实现了一下,这里记录一下,主要是date函数和strtotime函数的应用
$stand = "2013-01-"; for ($i = 1; $i <= 31; $i ++) { $time = strtotime($stand . $i); $date[] = date("Ymd", $time); } print_r($date); ?>
//日期定义 $day = date("Ymd", strtotime("-1 day")); echo $day."\n"; $day = date("Ymd", strtotime("+1 day")); echo $day."\n";