Simple javascript function to format the date as YYYY-MM-DD

Tired of concatenating Date.getYear() Date.getMonth(), and Date.getDay() to format todays date in Javascript?

Heres a simple javscript function I use to output the date in YYYY-MM-DD format

Code

Result

Justin Kelly

Justin Kelly

Web Developer, Business Analytics, Data Engineer specialising in PHP, ReactJS, Tableau, AWS RedShift and Matillion ETL

Based in Melbourne, Australia

Feel free to contact me justin@kelly.org.au or _justin_kelly

Leave a comment

Name Notify me of replies by email.