一个关于时间问题

littlebirds 2012-02-14 11:51:29
当前的日期通过控件获得:
$thisday = $_GET['calendar'];

现在我想求这个日期的前一天(查询日历日期的前一天),怎么求?

注:日历的字符串形式 Y-m-d
...全文
42 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
littlebirds 2012-02-14
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 xuzuning 的回复:]

echo date('Y-m-d', strtotime("-1 day $thisday"));
[/Quote]

学习了。谢谢!
iorichina 2012-02-14
  • 打赏
  • 举报
回复
如果$_GET['calendar']的时间格式类似“2012-02-14 11:56:30”,则先转换为time格式:strtotime($_GET['calendar'])
然后减去一天的秒数就可以啦:strtotime($_GET['calendar'])-60*60*24

xuzuning 2012-02-14
  • 打赏
  • 举报
回复
echo date('Y-m-d', strtotime("-1 day $thisday"));
床上等您 2012-02-14
  • 打赏
  • 举报
回复
-1day

21,882

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧