Created
January 12, 2022 21:42
-
-
Save mark05e/e620784e23c9ea9beeb610623a83046b to your computer and use it in GitHub Desktop.
Convert a UTC datetime to browser local datetime.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var utcDatetime = "01/12/2022 07:57 PM" | |
var options = {day: '2-digit', month: '2-digit', year: '2-digit', hour: '2-digit', minute:'2-digit' }; | |
var myDateTime = new Date(utcDatetime + ' UTC').toLocaleString("en-US",options) | |
// myDateTime : 01/12/22, 02:57 PM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment