<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-format-a-date-with-javascript-date-formatting-in-js-ygmwswqab" -->

---
title: How to Format a Date with JavaScript – Date Formatting in JS
description: In JavaScript, there is no direct syntax that provides you with your expected format because date format varies based on location, circumstance, and so on. It...
canonical: https://daily.dev/posts/how-to-format-a-date-with-javascript-date-formatting-in-js-ygmwswqab
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to Format a Date with JavaScript – Date Formatting in JS | daily.dev
og:description: In JavaScript, there is no direct syntax that provides you with your expected format because date format varies based on location, circumstance, and so on. It...
og:url: https://daily.dev/posts/how-to-format-a-date-with-javascript-date-formatting-in-js-ygmwswqab
og:image: https://api.daily.dev/og/posts/ygmWsWqAb.png
og:image:alt: How to Format a Date with JavaScript – Date Formatting in JS
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Format a Date with JavaScript – Date Formatting in JS

**[freeCodeCamp](https://daily.dev/sources/freecodecamp)** · [@olawanlejoel](https://daily.dev/olawanlejoel) · 4 min read · 17 upvotes · 2 comments

## Summary

In JavaScript, there is no direct syntax that provides you with your expected format because date format varies based on location, circumstance, and so on. It provides methods to work with dates and times effectively. In this article, we'll explore various techniques to format dates in JavaScript, enabling you to present dates in your desired format.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.freecodecamp.org/news/how-to-format-a-date-with-javascript-date-formatting-in-js/>

## Community discussion

Top comments from developers on daily.dev.

**@riedel** · 0 upvotes

> Can't wait for the new Temporal JS API to become the new norm.

**@yaireo** · 0 upvotes

> Hi good people! I've made a nice tiny little tool a few years ago to convert a date object or timestamp to a relative time string
>
> https://github.com/yairEO/relative-time
>
> Please use my code, it will make me so very happy!

---

Tags: [#javascript](https://daily.dev/tags/javascript)

[View this post on daily.dev](https://daily.dev/posts/how-to-format-a-date-with-javascript-date-formatting-in-js-ygmwswqab)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to Format a Date with JavaScript – Date Formatting in JS","url":"https://daily.dev/posts/how-to-format-a-date-with-javascript-date-formatting-in-js-ygmwswqab","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-format-a-date-with-javascript-date-formatting-in-js-ygmwswqab"},"datePublished":"2023-05-31T18:38:32.128Z","dateModified":"2023-07-20T14:10:56.027Z","description":"In JavaScript, there is no direct syntax that provides you with your expected format because date format varies based on location, circumstance, and so on. It...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/dbefff981c4f56f826756dea8559f9c9?_a=AQADKdt","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/dbefff981c4f56f826756dea8559f9c9?_a=AQADKdt","isAccessibleForFree":true,"articleSection":"freeCodeCamp","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Person","name":"Olawanle Joel","url":"https://daily.dev/olawanlejoel","image":"https://avatars.githubusercontent.com/u/57611810?v=4","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":390}},"commentCount":2,"discussionUrl":"https://daily.dev/posts/how-to-format-a-date-with-javascript-date-formatting-in-js-ygmwswqab","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":17},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":2}],"keywords":"javascript","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"freeCodeCamp","item":"https://daily.dev/sources/freecodecamp"},{"@type":"ListItem","position":3,"name":"How to Format a Date with JavaScript – Date Formatting in JS"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/how-to-format-a-date-with-javascript-date-formatting-in-js-ygmwswqab","comment":[{"@type":"Comment","text":"Can’t wait for the new Temporal JS API to become the new norm.","datePublished":"2023-06-06T10:46:47.123Z","url":"https://daily.dev/posts/ygmWsWqAb#c-DVcJBczWT","author":{"@type":"Person","name":"Tobias Riedel","url":"https://daily.dev/riedel","image":"https://media.daily.dev/image/upload/s--2kMUEbyV--/f_auto/v1748940978/avatars/avatar_k9AYHbt5BmUUYDArpynPJ?_a=BAMClqUq0"}},{"@type":"Comment","text":"Hi good people! I’ve made a nice tiny little tool a few years ago to convert a date object or timestamp to a relative time string\nhttps://github.com/yairEO/relative-time\nPlease use my code, it will make me so very happy!","datePublished":"2023-06-06T13:04:58.034Z","url":"https://daily.dev/posts/ygmWsWqAb#c-AupAnEIiL","author":{"@type":"Person","name":"Yair Even Or","url":"https://daily.dev/yaireo","image":"https://avatars.githubusercontent.com/u/845031?v=4"}}]}
```

