You can use
new Date(date).toLocaleDateString();
Answer from Viplav Soni on Stack Overflow Top answer 1 of 6
58
You can use
new Date(date).toLocaleDateString();
2 of 6
40
Date.parse returns a number. You are looking for new Date. Or, if time already is a Date instance, just use time.toLocaleDateString() (and make sure it really is in every call to the function)!
function formatTime(time, prefix = "") {
return typeof time == "object" ? prefix + time.toLocaleDateString() : "";
}
Bobby Hadz
bobbyhadz.com › blog › javascript-typeerror-tolocaledatestring-is-not-a-function
TypeError: toLocaleDateString is not a function in JS [Fix] | bobbyhadz
Copied!const d1 = new Date().toLocaleDateString('en-US'); console.log(d1); const d2 = new Date('Sept 24, 22 13:20:18').toLocaleDateString( 'en-US', ); console.log(d2); // 👉️ 9/24/2022 ... You can get a date object by passing a valid date to the Date() constructor. Note that if an invalid date is passed to the Date() constructor, you would get "Invalid date" back.
Bug Report - Other: TypeError: _a.toLocaleDateString is not a function
Vortex Version: 1.11.0-beta Memory: 31.87 GB System: win32 x64 (10.0.22631) Component rendering error Vortex Version: 1.11.0-beta, TypeError: _a.toLocaleDateString is not a function at remainingBar (C:\Users\Paint\AppData\Roaming\Vortex\... More on github.com
javascript - toLocaleDateString is not a function in react jsx render - Stack Overflow
Im trying to convert my date into a readable format, it current outputs as 2019-02-22T20:23:52.011Z I tried adding the .toLocaleDateString to format this date but I keep getting the same error of More on stackoverflow.com
Can't get .toLocaleDateString('en-GB') to work keeps it as US
I am using the following code to return a GB date and time format but it just won’t change it from a US format What am i doing wrong. const sd = new Date() const SysDate = sd.toLocaleDateString(‘en-GB’) const Systime = sd.toLocaleTimeString(‘en-GB’, {timeStyle: ‘short’ } ) More on forum.wixstudio.com
Date format looks different on brave compared to edge and firefox
I am working on a project where i need to format the date to get the data i need and the date is formatted as 05-July. Below is the code i have to format the date: function dateFormated() { return new Date() .toLocaleDateString("default", { day: "2-digit", month: "short" }) .replace(" ", "-"); ... More on forum.freecodecamp.org
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toLocaleDateString
Date.prototype.toLocaleDateString() - JavaScript | MDN
The locales and options parameters may not be supported in all implementations, because support for the internationalization API is optional, and some systems may not have the necessary data. For implementations without internationalization support, toLocaleDateString() always uses the system's locale, which may not be what you want. Because any implementation that supports the locales and options parameters must support the Intl API, you can check the existence of the latter for support: ... function toLocaleDateStringSupportsLocales() { return ( typeof Intl === "object" && !!Intl && typeof Intl.DateTimeFormat === "function" ); }
GitHub
github.com › Nexus-Mods › Vortex › issues › 15567
Bug Report - Other: TypeError: _a.toLocaleDateString is not a function · Issue #15567 · Nexus-Mods/Vortex
April 20, 2024 - Vortex Version: 1.11.0-beta Memory: 31.87 GB System: win32 x64 (10.0.22631) Component rendering error Vortex Version: 1.11.0-beta, TypeError: _a.toLocaleDateString is not a function at remainingBar (C:\Users\Paint\AppData\Roaming\Vortex\...
Author VortexFeedback
W3Schools
w3schools.com › jsref › jsref_tolocaledatestring.asp
JavaScript Date toLocaleDateString() Method
The toLocaleDateString() method returns the date (not the time) of a date object as a string, using locale conventions. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: ...
ServiceNow Community
servicenow.com › community › developer-forum › tolocaledatestring-is-not-working-in-server-side-script › td-p › 1441723
Solved: toLocaleDateString is not working in server side s... - ServiceNow Community
March 28, 2022 - toLocaleDateString does not seem to be supported Created a custom Japanese calendar conversion script ... You will need to use this script instead of toLocaleDateString to get the same functionality as per your requirement, just change the code as per your req:
Top answer 1 of 2
3
you can use
{new Date(**your date**).toLocaleDateString()}
Cheers !
2 of 2
1
Thanks to @mplungjan the issue here was item.CreateDate.S was not a date object,
I then had to use
Date Purchased: {new Date(item.CreateDate.S).toLocaleDateString()}
instead of
Date Purchased: {item.CreateDate.S.toLocaleDateString()}
Can I Use
caniuse.com
"toLocaleDateString" | Can I use... Support tables for ...
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
freeCodeCamp
forum.freecodecamp.org › t › date-format-looks-different-on-brave-compared-to-edge-and-firefox › 620860
Date format looks different on brave compared to edge and firefox - The freeCodeCamp Forum
July 5, 2023 - I am working on a project where i need to format the date to get the data i need and the date is formatted as 05-July. Below is the code i have to format the date: function dateFormated() { return new Date() .toLocaleDateString("default", { day: "2-digit", month: "short" }) .replace(" ", "-"); } It shows incorrectly on brave July-05, but on Firefox and edge it shows the correct way i formatted 05-July.
Moment.js
momentjs.com › docs
Moment.js | Docs
Modern JavaScript environments will also implement the ECMA-402 specification, which provides the Intl object, and defines behavioral options of the Date object's toLocaleString, toLocaleDateString, and toLocaleTimeString functions. When using the Intl object, be aware of the following: Not every ...
TutorialsPoint
tutorialspoint.com › javascript › date_tolocaledatestring.htm
JavaScript Date toLocaleDateString() Method
We are also setting the locale to "en-US" − · <html> <body> <script> const today = new Date(); const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }; const dateString = today.toLocaleDateString('en-US', options); document.write(dateString); </script> </body> </html>
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toLocaleTimeString
Date.prototype.toLocaleTimeString() - JavaScript | MDN
October 30, 2025 - For implementations without internationalization support, toLocaleTimeString() always uses the system's locale, which may not be what you want. Because any implementation that supports the locales and options parameters must support the Intl API, you can check the existence of the latter for support: ... function toLocaleTimeStringSupportsLocales() { return ( typeof Intl === "object" && !!Intl && typeof Intl.DateTimeFormat === "function" ); }