Javascript Format Date Time as UTC

Jul 27, 2021

To UTC

new Date().toISOString() // 2021-07-27T08:33:50.576Z

Format US yyyy-MM-DD HH:mm

new Date().toISOString().replace(/:\d{2}\.\d{3}Z$/g, "").replace('T', ' '); // 2021-07-27 08:33

toLocaleTimeString

const options = { year: 'numeric', month: 'short', day: 'numeric',  timeZone: 'UTC' }new Date().toLocaleTimeString('en-US', options) // Jul 27, 2021, 8:33:50 AM

References:

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.