31 lines
912 B
PHP
31 lines
912 B
PHP
<?php
|
|
|
|
// https://css-tricks.com/php-date-and-time-recipes/
|
|
|
|
$currentLocale = setlocale(LC_ALL, 0);
|
|
echo $currentLocale;
|
|
|
|
$locale = getenv('LC_ALL=');
|
|
echo "Locale: " . $locale;
|
|
|
|
/*
|
|
$timezone = new DateTimeZone("Europe/Paris");
|
|
$date = new DateTime("2021-10-13 05:00", $timezone);
|
|
var_dump($date);
|
|
*/
|
|
|
|
$locale = "fr_FR.UTF-8";
|
|
$formatter = new IntlDateFormatter($locale, IntlDateFormatter::FULL, IntlDateFormatter::SHORT, "Europe/Paris");
|
|
$date = new DateTime("2020-10-10 00:00 UTC");
|
|
echo $formatter->format($date);
|
|
// samedi 10 octobre 2020 à 08:00 ; Asia/Singapore
|
|
// samedi 10 octobre 2020 à 02:00 ; Europe/Paris
|
|
|
|
|
|
$locale = "fr_FR.UTF-8";
|
|
$formatter = new IntlDateFormatter($locale, IntlDateFormatter::LONG, IntlDateFormatter::NONE, "Europe/Paris");
|
|
$date = new DateTime("2020-10-10 00:00 UTC");
|
|
echo $formatter->format($date);
|
|
// 10 octobre 2020 ; Europe/Paris
|
|
// 10 octobre 2020 ; Asia/Singapore
|
|
?>
|