DEV Community

Mursal Furqan Kumbhar
Mursal Furqan Kumbhar

Posted on

4

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

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay