Fonction PHP date_interval_format()
Exemple
Calculez l'intervalle entre deux dates, puis formatez l'intervalle :
<?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.");
?>
Définition et utilisation
La fonction date_interval_format() est un alias de DateInterval::format().
La fonction DateInterval::format() est utilisée pour formater l'intervalle.
Syntaxe
DateInterval::format(format)
Valeurs des paramètres
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! |
Détails techniques
Valeur de retour : | Renvoie l'intervalle formaté |
---|---|
Version PHP : | 5.3+ |
Journal des modifications PHP : | PHP 7.1 : Ajout des paramètres F et f |
❮ Référence date/heure PHP