Home  >  Article  >  Backend Development  >  How to add one month to time in php

How to add one month to time in php

L
LOriginal
2020-06-02 12:13:426551browse

How to add one month to time in php

phpHow to add one month to the time

Use php’s strtotime() function

Example: For example, the current time is "2010-10-06", plus one month. 1653

echo   date("Y-m-d", strtotime("+1 months", strtotime("2010-10-06")));

Specific application examples of strtotime in php:

<?php
echo(strtotime("now"));
echo(strtotime("3 October 2005"));
echo(strtotime("+5 hours"));
echo(strtotime("+1 week"));
echo(strtotime("+1 week 3 days 7 hours 5 seconds"));
echo(strtotime("next Monday"));
echo(strtotime("last Sunday"));
?>

Recommended tutorial: "PHP Tutorial"

The above is the detailed content of How to add one month to time in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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