Support formatting milliseconds with Intl.DateTimeFormat API #300
Comments
|
Or maybe something more generic for the sub-second part, like the "S" format in ICU. |
|
Is this getting resolved via #347? That seems to match the API in MDN's docs of Intl.DateTimeFormat: (paraphrased) // sometimes you want to be very precise
var options = {
hour: 'numeric', minute: 'numeric', second: 'numeric',
timeZone: 'Australia/Sydney',
timeZoneName: 'short',
fractionalSecondDigits: 3,
};
console.log(new Intl.DateTimeFormat('en-AU', options).format(date));
// → "2:00:00.200 pm AEDT"An alternative that more closely matches the other option values ( // sometimes you want to be very precise
var options = {
hour: 'numeric', minute: 'numeric', second: 'numeric',
timeZone: 'Australia/Sydney',
timeZoneName: 'short',
// 'narrow' => '.0'
// 'short' => '.00'
// 'long' => '.000'
fractionalSecond: 'long',
};
console.log(new Intl.DateTimeFormat('en-AU', options).format(date));
// → "2:00:00.200 pm AEDT" |
|
Seems that way. |
|
Yes, this is #347. Sorry for the long name; we arrived at |
|
Thank you for all your work. Especially @FrankYFTang ! |
I need to format a Timestamp in a specific locale (not utc, not browser locale). But I must have the millisecond part of the date, too. My first attempt was
second:'numeric'with the DateTimeFormat API:But the result is something like
26.11.2018, 09:31:04and not26.11.2018, 09:31:04,243.Asked first at stackoverflow.
The text was updated successfully, but these errors were encountered: