PHP date_interval_format() function

PHP date_interval_create_from_date_string() function
PHP date_isodate_set() function

In this article, you will learn the PHP date_interval_for() function to format the interval. It is an alias of the DateInterval::format() function.

What is the syntax of the date_interval_format() function in PHP?

DateInterval::format(format)
ParametersDetails
formatSpecify the format – Required
PHP date_interval_format() method

Examples of the date_interval_format() function

Example 1. In the following example, we simply calculate the difference between two dates.

<?php
$date_1=date_create("2021-01-01");
$date_2=date_create("2017-04-10");
$diff=date_diff($date_1,$date_2);

echo $diff->format("Difference is: %a.");
?>
PHP date_interval_create_from_date_string() function
PHP date_isodate_set() function
en English
X
Scroll to Top