菜单

PHP implements the addition and subtraction operations for dates, months, days, weeks, hours, minutes, seconds and so on

2017年11月22日 - PHPer

In this paper, an example is given to illustrate how PHP implements the addition and subtraction method for dates, months, days, weeks, hours, minutes, seconds and so on. To share with you for your reference, as follows:

It’s actually the built-in function of strtotime

//PHP date plus minus week

Date (“Y-m-d”, strtotime (“2013-11-12 +1 week”))

//PHP date plus and minus days

Date (“Y-m-d”, strtotime (“2013-11-12 12:12:12 +1 day”))

//PHP date plus minus hours

Date (“Y-m-d h:i:s”, strtotime (“2013-11-12 12:12:12 +1 hour”))

//PHP date plus minus month number

Date (“Y-m-d”, strtotime (“2013-11-12 12:12:12 +1 month”))

//PHP date addition and subtraction

Date (“Y-m-d h:i:s”, strtotime (“2013-11-12 12:12:12 +1 minute”))

//PHP date plus minus seconds

Date (“Y-m-d h:i:s”, strtotime (“2013-11-12 12:12:12 +1 second”))

发表评论

电子邮件地址不会被公开。