27.4 C
HomeJavascriptJavascript convert date to long date format

Javascript convert date to long date format

➜For accomplishing this we will be using the toLocaleDateString() function of JavaScript. It’s very simple to use this function but by default, this function will show the date in the format dd/m/yyyy. but we can provide optional parameter options to it which will be a map providing information about how to display various components of a date. Below is a list of the parameter names and types that are available when formatting time strings.

💡 Options key

1️⃣ day:
➜ The representation of the day.
➜ Possible values are “numeric”, “2-digit”.
2️⃣ weekday:
➜ The representation of the weekday.
➜ Possible values are “narrow”, “short”, “long”.
3️⃣ year:
➜ The representation of the year.
➜ Possible values are “numeric”, “2-digit”.
4️⃣ month:
➜ The representation of the month.
➜ Possible values are “numeric”, “2-digit”, “narrow”, “short”, “long”.
5️⃣ hour:
➜ The representation of the hour.
➜ Possible values are “numeric”, “2-digit”.
6️⃣ minute:
➜ The representation of the minute.
➜ Possible values are “numeric”, “2-digit”.
7️⃣ second:
➜ The representation of the second.
➜ Possible values are “numeric”, 2-digit”.

🌐 For different languages:

  1. “en-US”: For English
  2. “hi-IN”: For Hindi

➜ You can use more language options

var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
var today  = new Date();

console.log(today.toLocaleDateString("en-US", options)); 
console.log(today.toLocaleDateString("hi-IN", options)); 


Javascript convert date to long date format
👉 Here are some JavaScript projects you should check out:

➜ Certificate Generator Website in JavaScript
➜ To-Do List using JavaScript,HTML and CSS (Beginners)
➜ Custom Pagination in JavaScript(beginners)
 Build A Dictionary app using JavaScript
➜ Bookmarker Application in javascript
➜ Speed Typing Game using JavaScript
➜ Simple snake game in JavaScript

Rocoderes is a blog you can learn HTML, CSS, JavaScript, React Js and Python along with creative coding stuff and free source code files.


  1. Hello this is kinda of off topic but I was wondering if
    blogs use WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding know-how so I
    wanted to get advice from someone with experience. Any
    help would be enormously appreciated!

  2. I’m not sure why but this site is loading incredibly slow for me.
    Is anyone else having this problem or is it a issue on my end?
    I’ll check back later on and see if the problem still

  3. hello!,I really like your writing very a lot! proportion we keep
    up a correspondence extra approximately your article on AOL?
    I require an expert on this area to resolve my problem.
    Maybe that’s you! Having a look ahead to see you.

  4. Hey! I could have sworn I’ve been to this website before but after reading through some of the post I realized it’s new to me.
    Nonetheless, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  5. This is a really good tip especially to those new to the
    blogosphere. Simple but very accurate info… Thanks
    for sharing this one. A must read article!


Please enter your comment!
Please enter your name here

- Advertisment -spot_img

Subscribe to our newsletter

To be updated with all the latest news, offers and special announcements.

Most Popular