PHP - Funktion date_interval_format()
Beispiel
Berechnen Sie das Intervall zwischen zwei Daten und formatieren Sie dann das Intervall:
<?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.");
?>
Definition und Verwendung
Die Funktion date_interval_format() ist ein Alias von DateInterval::format().
Die Funktion DateInterval::format() wird verwendet, um das Intervall zu formatieren.
Syntax
DateInterval::format(format)
Parameterwerte
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! |
Technische Details
Rückgabewert: | Gibt das formatierte Intervall zurück |
---|---|
PHP-Version: | 5.3+ |
PHP-Änderungsprotokoll: | PHP 7.1: Parameter F und f hinzugefügt |
❮ PHP-Datums-/Zeitreferenz