DEV Community

Mursal Furqan Kumbhar
Mursal Furqan Kumbhar

Posted on

JavaScript Date Cheatsheet

Getting our dates right and proper order has always been a tough job for us developers, me, specially. So here is the JavaScript Date Cheatsheet by me. It contains most of the methods that we can use to mold the date into our desired format.

I have not mentioned the outputs here. That are for you to see and experience 😉
Link to working code

JS Get Date Methods

todayDate.getDate()
todayDate.getDay()
todayDate.getMonth()
todayDate.getFullYear()
todayDate.getYear()
todayDate.getHours()
todayDate.getMinutes()
todayDate.getSeconds()
todayDate.getMilliseconds()
todayDate.getTime()
todayDate.getTimezoneOffset()
Enter fullscreen mode Exit fullscreen mode

UTC - Universal Time Coordinated

todayDate.getUTCDate()
todayDate.getUTCDay()
todayDate.getUTCMonth()
todayDate.getUTCFullYear()
todayDate.getUTCHours()
todayDate.getUTCMinutes()
todayDate.getUTCSeconds()
todayDate.getUTCMilliseconds()
Enter fullscreen mode Exit fullscreen mode

JS Set Date Methods

todayDate.setDate(15)
todayDate.setMonth(11)
todayDate.setFullYear(2021)
todayDate.setHours(10)
todayDate.setMinutes(30)
todayDate.setSeconds(30)
todayDate.setMilliseconds(500)
todayDate.setTime(1000000000000)
Enter fullscreen mode Exit fullscreen mode

JS Date Parse Methods

todayDate.toString()
todayDate.toDateString()
todayDate.toLocaleString()
todayDate.toGMTString()
todayDate.toUTCString()
Enter fullscreen mode Exit fullscreen mode

Top comments (0)