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

WBOY
Release: 2016-06-13 12:55:08
Original
982 people have browsed it

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

需求

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


php实现代码

$stand = "2013-01-";

for ($i = 1; $i 
Copy after login

实现效果




date函数获取前一天或后一天日期

php代码

//日期定义
$day = date("Ymd", strtotime("-1 day"));
echo $day."\n";
$day = date("Ymd", strtotime("+1 day"));
echo $day."\n";
Copy after login

效果


Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!