I'm trying to use JS to turn a date object
into a string in YYYYMMDD
format. Is there an easier way than concatenating Date.getYear()
, Date.getMonth()
, and Date.getDay()
?
Javascript – Get String in YYYYMMDD format from JS date object
datedate-formattingjavascript
Related Topic
- Javascript – find documentation on formatting a date in JavaScript
- Javascript – Detecting an “invalid date” Date instance in JavaScript
- Javascript – event.preventDefault() vs. return false
- Javascript – How to get the current date in JavaScript
- Javascript – How to format a JavaScript date
- Javascript – How to check if an object is an array?
- Javascript – How to remove a specific item from an array
Best Answer
Altered piece of code I often use: