Created
December 27, 2021 09:42
-
-
Save mailtodanish/ec5e321aae13541c5ecb10731d95725a to your computer and use it in GitHub Desktop.
Format date in java script
This file contains 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
//format date in JS | |
let d = new Date(2010, 7, 5); | |
function formatted_date(d){ | |
let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d); | |
let mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(d); | |
let da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d); | |
return `${da}-${mo}-${ye}`; | |
} | |
formatted_date(d); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment