PHP date_add() function

PHP checkdate() function
PHP date_create_from_format() Function

In this article, you will learn how to add some days, months, years, hours, minutes, or seconds to a date. The PHP date_add() function does the job for us.

What is the syntax of the function in PHP?

date_add(object, interval)
ParameterDescription
objectDateTime object – Required
intervalDateInterval object – Required
PHP date_add() method

Examples of date_add() function

Example 1. In the following example, we add 30 days to the 04 of January 1998.

<?php
$d=date_create("1998-01-04");
date_add($d,date_interval_create_from_date_string("30 days"));
echo date_format($d,"Y-m-d");
?>
PHP checkdate() function
PHP date_create_from_format() Function
en English
X
Scroll to Top