How to get current date in Javascript

Last updated on Sep 21, 2022 by Suraj Sharma

In this tutorial, you will learn how to get the current date as a string in Javascript

The toLocaleDateString() method returns the date as a string in your timezone format.

  new Date().toLocaleDateString()
  // '21/09/2022'

The toLocaleDateString() method accepts two arguments locales and options. For reference.

  const options = {day: 'numeric', month: 'numeric', year: 'numeric'}
  new Date().toLocaleDateString('en-US', options)
  // '9/21/2022'

Get the current UTC date

To get the current UTC date, we set the options' timeZone property to UTC

  const options = {
    day: 'numeric',
    month: 'numeric', 
    year: 'numeric',
    timeZone: 'UTC'
  new Date().toLocaleDateString('de-DE', options)
  // '21.9.2022'

Related Solutions

Rate this post

Suraj Sharma is a Full Stack Software Engineer. He holds a B.Tech degree in Computer Science & Engineering from NIT Rourkela.