Home > Article > Backend Development > PHP method to implement addition and subtraction operations for dates, months, days, weeks, hours, minutes, seconds, etc.
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"))
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!