0

Is there a function which will help us to write the date using the Locale settings in Javascript.For example in my machine as per the Locale settings the format is M/D/YYYY so in my program the date should be printed in this format. If i change my the Locale settings in computer format to YYYY-MM-DD then my program should automatically print in this format without hardcoding the format. This is the expected behavior of my program. As some of the suggestions given on using toLocaleDateString method, On using toLocaleDateString it always returns in M/D/YYYY format only even then the computer Date format is changed to YYYY-MM-DD. I searched in internet i don't find any proper answer please guide me to do this. Any help is appreciated.

shaaa
  • 227
  • 1
  • 7
  • 22
  • 1
    Yes! Read about [`toLocaleDateString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString). – 31piy Jun 10 '18 at 07:21
  • _If i change my the Locale settings format..._ How exactly do you change the settings? in the computer settings or browser settings? – JohnnyJS Jun 10 '18 at 07:33
  • @JonnieJS am changing format in computer settings – shaaa Jun 10 '18 at 08:13
  • @31piy i checked toLocaleDateString function but it is always returning in M/D/YYYY format even then i change my computer settings to YYYY-MM-DD. Please suggest if i need to do anything else. – shaaa Jun 10 '18 at 08:28
  • https://michelebusta.com/angular-tip-date-and-time-locale-formatting-fb6563a775cc – JGFMK Jun 10 '18 at 13:15
  • @JGFMK am looking for the format when computer date format is changed. – shaaa Jun 11 '18 at 05:16

0 Answers0