PHP date_sub() 函数
PHP 教程
· 2019-01-23 22:13:53
实例
从 2013 年 3 月 15 日减去 40 天:
<?php
$date=date_create("2013-03-15");
date_sub($date,date_interval_create_from_date_string("40 days"));
echo date_format($date,"Y-m-d");
?>
$date=date_create("2013-03-15");
date_sub($date,date_interval_create_from_date_string("40 days"));
echo date_format($date,"Y-m-d");
?>
定义和用法
date_sub() 函数从指定日期减去日、月、年、时、分和秒。
语法
date_sub(object,interval);
| 参数 | 描述 |
|---|---|
| object | 必需。规定一个由 date_create() 返回的 DateTime 对象。 |
| interval | 必需。规定一个 DateInterval 对象。 |
技术细节
| 返回值: | 如果成功则返回 DateTime 对象,如果失败则返回 FALSE。 |
|---|---|
| PHP 版本: | 5.3+ |
点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html
Responsive Web Design
Ethan Marcotte / Happy Cog / 2011-6 / USD 18.00
From mobile browsers to netbooks and tablets, users are visiting your sites from an increasing array of devices and browsers. Are your designs ready? Learn how to think beyond the desktop and craft be......一起来看看 《Responsive Web Design》 这本书的介绍吧!