note 126973 added to intldateformatter.formatobject
| From: | raf at sns dot pm | Date: | Thu, 07 Apr 2022 02:44:25 +0000 |
| Subject: | note 126973 added to intldateformatter.formatobject | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-218133@lists.php.net to get a copy of this message | ||
If you want to format a date according to a specific scheme and in a local language, here is the
link to the reference of the formatting codes to use, I did not find it directly in the
documentation:
https://unicode-org.github.io/icu/userguide/format_parse/datetime/#date-field-symbol-table
Here is a test using a DateTime object :
<?php
// must be required by the server
date_default_timezone_set( 'Europe/Paris' );
// instantiate a new DateTime object
$dateTimeObj = new DateTime('now', new DateTimeZone('Europe/Paris'));
// format the date with a specific scheme
// the 3 parameters are [ DateTimeObject, ICU Scheme, locale code string ]
$dateFromatted = IntlDateFormatter::formatObject( $dateTimeObj, "eee d MMMM y à HH:mm",
'fr' );
// test :
echo ucwords($dateFromatted);
// output : Jeu. 7 Avril 2022 Ã 04:36 // formatted as i want
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.135 (proxied: 2a01:e0a:2dc:b8f0:611:9045:b83c:4303)
----
Manual Page -- https://php.net/manual/en/intldateformatter.formatobject.php
Edit -- https://main.php.net/note/edit/126973
Del: integrated -- https://main.php.net/note/delete/126973/integrated
Del: useless -- https://main.php.net/note/delete/126973/useless
Del: bad code -- https://main.php.net/note/delete/126973/bad+code
Del: spam -- https://main.php.net/note/delete/126973/spam
Del: non-english -- https://main.php.net/note/delete/126973/non-english
Del: in docs -- https://main.php.net/note/delete/126973/in+docs
Del: other reasons-- https://main.php.net/note/delete/126973
Reject -- https://main.php.net/note/reject/126973
Search -- https://main.php.net/manage/user-notes.php