scripts examples
This commit is contained in:
31
_date.php
Normal file
31
_date.php
Normal 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
|
||||
?>
|
||||
Reference in New Issue
Block a user