scripts examples

This commit is contained in:
2024-12-10 11:16:23 +01:00
parent 4fa387e8af
commit 513b4645c7
2 changed files with 177 additions and 0 deletions

31
_date.php Normal file
View File

@@ -0,0 +1,31 @@
<?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
?>