All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
一个处理PHP中时间加减的函数_[PHP教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/2/17 7:41:14 Browse times: 419 Comment times: 0

一个处理PHP中时间加减的函数_[PHP教程]


Head photo

Go homepage
Upload pictures
Write articles

一个处理PHP中时间加减的函数_[PHP教程] 在开发过程当中对于时间的操作很是让人头疼。在PHP文档中找到了一个很好的函数,可以对时间进行加减,还是很有意思的。
int strtotime ( string time [, int now] ) 
返回类型 int
函数可用于时间转换和加减。
下面将举个小例子,获得当前时间加上一周后的时间。
例子:
//获得当前时间
//date()格式化时间返回String类型。
$current_date = date(’Y-m-d’,time());
//根据当前时间加一周后
$weekLater = date(’Y-m-d’,strtotime("$current_date + 1 week"));
echo $weekLate;
// 2009-05-26 加一天的日期
$tomorrow = date(’Y-m-d’,strtotime("2009-05-26 + 1 day"));
echo $tomorrow; // 2009-05-27




There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.