Funkce PHP date_interval_format().
Příklad
Vypočítejte interval mezi dvěma daty a poté interval naformátujte:
<?php
$date1=date_create("2013-01-01");
$date2=date_create("2013-02-10");
$diff=date_diff($date1,$date2);
// %a outputs the total number of days
echo $diff->format("Total number of days: %a.");
?>
Definice a použití
Funkce date_interval_format() je aliasem DateInterval::format().
K formátování intervalu se používá funkce DateInterval::format().
Syntax
DateInterval::format(format)
Hodnoty parametrů
Parameter | Description |
---|---|
format | Required. Specifies the format. The following characters can be used in the format parameter string:
Note: Each format character must be prefixed by a % sign! |
Technické údaje
Návratová hodnota: | Vrátí formátovaný interval |
---|---|
Verze PHP: | 5,3+ |
PHP Changelog: | PHP 7.1: Přidány parametry F a f |
❮ Reference data/času PHP