question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question / Feature request regarding localized time format

See original GitHub issue

This may be possible, but I couldn’t find it in the docs. I would like to display a time in a users locally preferred format—either 24h or 12h with am/pm. I tried localizedFormat with ‘LT’, but that gives me 1:36 PM in the UK, where the preferred time format is 24h (as returned by new Date().toLocaleString().

Is there a way to show a time either as HH:mm or h:mm a depending on the user’s locale / machine preferences?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
dsl101commented, Jan 22, 2021

For what it’s worth, in my use case, using native JS Date objects rather than dayjs is probably the right answer:

d.toLocaleTimeString(undefined, { hour: 'numeric', minute: 'numeric', timeZoneName: 'short' } )

gives exactly the output I’m after in all locales tested so far.

1reaction
dsl101commented, Jan 21, 2021

Another plugin? I must admit I had thought that’s exactly what LocalizedFormat was supposed to do…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Date time formats and export feature request (potential bug)
I am comparing activity outside working hours from the para data with the exported time stamps (I converted paradata from UTS to local...
Read more >
Localize time format in Calendar widget - Mendix Forum
The Calendar widget is based on the (JS) Full Calendar. The documentation mentions, and the code clearly shows, the usage of Locale to...
Read more >
java - SimpleDateFormat and locale based format string
The java. time classes use ISO 8601 formats by default for parsing/generating strings.
Read more >
Supported Date and Time Formats (ICU) - Salesforce Help
We use three variations of date and time formats across the Salesforce application: short, medium, and long. All three formats are listed for...
Read more >
Date - JavaScript - MDN Web Docs - Mozilla
Chrome Edge Date Full support. Chrome1. Toggle history Full support. Edge12. Toggle hist... @@toPrimitive Full support. Chrome47. Toggle history Full support. Edge15. Toggle hist... Date() constructor...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found