PHP method to implement addition and subtraction operations for dates, months, days, weeks, hours, minutes, seconds, etc.

墨辰丷
Release: 2023-03-27 17:40:02
Original
1906 people have browsed it

This article mainly introduces the PHP implementation of addition and subtraction operations for dates, months, days, weeks, hours, minutes, seconds, etc., and analyzes simple date and time operation techniques based on strtotime in the form of examples, which is very practical. Value, friends in need can refer to it

In fact, it is the built-in functionstrtotime


##

//PHP 日期 加减 周
date("Y-m-d",strtotime("2013-11-12 +1 week"))
//PHP 日期 加减 天数
date("Y-m-d",strtotime("2013-11-12 12:12:12 +1 day"))
//PHP 日期加减小时
date("Y-m-d h:i:s",strtotime("2013-11-12 12:12:12 +1 hour"))
//PHP 日期 加减 月数
date("Y-m-d",strtotime("2013-11-12 12:12:12 +1 month"))
//PHP 日期 加减 分
date("Y-m-d h:i:s",strtotime("2013-11-12 12:12:12 +1 minute"))
//PHP 日期 加减 秒
date("Y-m-d h:i:s",strtotime("2013-11-12 12:12:12 +1 second"))
Copy after login


The above is the entire content of this article, I hope it will be helpful to everyone's study.


Related recommendations:

PHPSummary of mathematical operation functions (classics worth collecting)_php skills

PHPHow to format MYSQL to return float type_php tips

PHPCollection of mathematical operation functions (classics worth collecting)_php skills


The above is the detailed content of PHP method to implement addition and subtraction operations for dates, months, days, weeks, hours, minutes, seconds, etc.. For more information, please follow other related articles on the PHP Chinese website!

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!