Date.prototype.toLocaleDateString()
Syntax:
toLocaleDateString()
toLocaleDateString(locales)
Example:
toLocaleDateString()
var date = new Date(e);
//e is an event with value on Jan 30 2023 00:00:00 GMT-0600 (Central Standard Time)
date.toLocaleDateString();
//Output : 1/30/2023
toLocaleDateString(locales): In order to get the format of the language used in the user interface of your application, make sure to specify that language (and possibly some fallback languages) using the locales argument
var date = new Date(e);
//e is an event with value on Jan 30 2023 00:00:00 GMT-0600 (Central Standard Time)
date.toLocaleDateString("en-GB");
//Output : 30/01/2023 format that British English uses day-month-year order
0 comments:
Post a Comment