在当前时间基础上,加减几天后是哪一天?

2026-06-11 14:457阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计140个文字,预计阅读时间需要1分钟。

在当前时间基础上,加减几天后是哪一天?

php


在当前时间基础上,加减几天后是哪一天?

<?php
//字符串转成日期的函数
$t = "2012-10-11 17:27:00"; // 当前时间戳
//$nowTime = strtotime('2012-10-11 16:30:00'); $nowTime = strtotime($t);
//$t = time(); // 当前时间戳//$t = strtotime("+30 days", time()); // 30天后的时间
//echo date("Y-m-d", strtotime("+30 days", time())); // 格式化日期
echo date("Y-m-d", strtotime("+30 days", $nowTime )); // 格式化日期 ?>
输出格式:2012-09-19
减少几小时
//echo date("Y-m-d H:i:s", strtotime("-1 hour", time())); // 格式化日期
echo date("Y-m-d H:i:s", strtotime("-1 hour", $nowTime )); // 格式化日期

本文共计140个文字,预计阅读时间需要1分钟。

在当前时间基础上,加减几天后是哪一天?

php


在当前时间基础上,加减几天后是哪一天?

<?php
//字符串转成日期的函数
$t = "2012-10-11 17:27:00"; // 当前时间戳
//$nowTime = strtotime('2012-10-11 16:30:00'); $nowTime = strtotime($t);
//$t = time(); // 当前时间戳//$t = strtotime("+30 days", time()); // 30天后的时间
//echo date("Y-m-d", strtotime("+30 days", time())); // 格式化日期
echo date("Y-m-d", strtotime("+30 days", $nowTime )); // 格式化日期 ?>
输出格式:2012-09-19
减少几小时
//echo date("Y-m-d H:i:s", strtotime("-1 hour", time())); // 格式化日期
echo date("Y-m-d H:i:s", strtotime("-1 hour", $nowTime )); // 格式化日期