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

Billboard image

Monitoring as code

With Checkly, you can use Playwright tests and Javascript to monitor end-to-end scenarios in your NextJS, Astro, Remix, or other application.

Get started now!

Top comments (0)

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay