Intl.DateTimeFormat custom pattern output

Muhammad Hussein Fattahizadeh semnanweb at gmail.com
Sun Aug 16 17:45:57 UTC 2015


​I want to use Intl.DateTimeFormat
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat>
but with custom pattern for output. I use this method for php version of
ICU dateformat and it's work well.

$fmt = datefmt_create(
    'fa_IR at calendar=persian',
    IntlDateFormatter::FULL,
    IntlDateFormatter::FULL,
    'Asia/Tehran',
    IntlDateFormatter::TRADITIONAL,
    'EEEE d MMMM yyyy HH:mm' // as ISO_8601);

echo datefmt_format($fmt, time()) . "\n";// پنجشنبه ۱۰ اردیبهشت ۱۳۹۴ ۱۲:۱۲

How can i set pattern as ICU documentation in Intl.DateTimeFormat like php
version of Intl/ICU date time formatter.

My javascript code

console.log(new Intl.DateTimeFormat('fa-IR-u-ca-persian').format(new
Date())); // ۱۳۹۴/۵/۲۵ ه‍.ش.

How can iset ISO_8601 pattern in my javascript format pattern like EEEE d
MMMM yyyy HH:mm or MM yy dd or etc ?

ISO_8601 <http://en.wikipedia.org/wiki/ISO_8601>

PHP IntlDateFormatter::format
<http://php.net/manual/en/intldateformatter.format.php>

ICU Date formatter
<http://www.icu-project.org/apiref/icu4c/udat_8h.html#details>

ICU Date formats
<http://www.icu-project.org/apiref/icu4c/classSimpleDateFormat.html#details>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150816/6cdbba96/attachment.html>


More information about the es-discuss mailing list