Is there a function in PHP to increment a specific date by 1 day, for example from 31st July 2005 to 1st August 2005?
To increment a specific date by 1 day in PHP, you can use the `strtotime()` function to convert the date to a Unix timestamp, then add 86400 seconds (which is equivalent to 1 day) to the timestamp, and finally convert the new timestamp back to a date format using the `date()` function.
$date = "2005-07-31";
$new_date = date('Y-m-d', strtotime($date . ' +1 day'));
echo $new_date;
Keywords
Related Questions
- How can a search index be created for both database tables and static HTML pages in PHP?
- In what situations would implementing a datepicker with jQuery be beneficial for ensuring accurate date input in PHP applications?
- What are some common methods to include ASCII characters in a PHP string, especially when the editor cannot display the character?