strtotime时间的处理
时间:2008-03-03 来源:liuxingyuyuni
?php
/**
* @company xingquan
* @auther BianJiang
* @date Mon Mar 03 11:03:15 CST 2008
* @copyright Shen Yang Xing Quan
* @todo 计算指定日期后5天的日期
* @desc strtotime将任何英文文本的日期时间描述解析为 Unix 时间戳
* strtotime处理日期相关的任务非常实用与灵活
*/
$timestamp = mktime(0, 0, 0, 3, 3, 2008);
//在当前的时间戳
$tomorrow = strtotime("+1days", $timestamp);
$yesterday = strtotime("-1days", $timestamp);
$nextWeek = strtotime("+1weeks", $timestamp);
$nextMonth = strtotime("+1month", $timestamp);
$nextYear = strtotime("+1year", $timestamp);
echo date("Y-m-d", $timestamp) . "\n";
echo "明天的时间是:" . date("Y-m-d", $tomorrow)."\n";
echo "昨天的时间是:" . date("Y-m-d", $yesterday)."\n";
echo "下周的时间是:" . date("Y-m-d", $nextWeek)."\n";
echo "下月的时间是:" . date("Y-m-d", $nextMonth)."\n";
echo "明年的时间是:" . date("Y-m-d", $nextYear)."\n";
//++++++++++++++++++++++++++++++++++++++++++++++++++
/**
* @todo 时间差计算
* */
$startDate = mktime(0, 0, 0, 2, 1, 2008);
$endDate = mktime(0, 0, 0, 3, 1, 2008);
$days = round(($endDate - $startDate)/3600/24);
echo $days;
?>
相关阅读 更多 +
排行榜 更多 +