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_sub() 函数从指定日期减去日、月、年、时、分和秒。

语法

date_sub(object,interval);

参数 描述
object 必需。规定一个由 date_create() 返回的 DateTime 对象。
interval 必需。规定一个 DateInterval 对象。

技术细节

返回值: 如果成功则返回 DateTime 对象,如果失败则返回 FALSE。
PHP 版本: 5.3+

点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

Web Scalability for Startup Engineers

Web Scalability for Startup Engineers

Artur Ejsmont / McGraw / 2015-6-23 / USD 34.81

Design and build scalable web applications quickly This is an invaluable roadmap for meeting the rapid demand to deliver scalable applications in a startup environment. With a focus on core concept......一起来看看 《Web Scalability for Startup Engineers》 这本书的介绍吧!

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试