DateInterval 怎么减少时间

WBOY
Release: 2016-06-13 10:27:25
Original
1069 people have browsed it

DateInterval 如何减少时间
比如这个代码是获取当前时间加上3个小时,那么如何获取减少3个小时呢?

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->(new \DateTime('NOW'))->add(new \DateInterval('PT3H'))
Copy after login


------解决方案--------------------
DateInterval::format() - Formats the interval
DateTime::add() - Adds an amount of days, months, years, hours, minutes and seconds to a DateTime object
DateTime::sub() - Subtracts an amount of days, months, years, hours, minutes and seconds from a DateTime object
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!