Home > Article > Web Front-end > How to convert a date to a string using the current locale's conventions?
JavaScript Date toLocaleString() The method converts a date to a string using the operating system's native convention.
The toLocaleString method relies on the underlying operating system for formatting dates. It converts the date to a string using the format conventions of the operating system the script is running on. For example, in the United States, the month appears before the date (04/15/98), while in Germany, the day appears before the month (15.04.98).
<html> <head> <title>JavaScript toLocaleString Method</title> </head> <body> <script> var dt = new Date(2018, 0, 15, 14, 39, 7); document.write( "Formated Date : " + dt.toLocaleString() ); </script> </body> </html>
The above is the detailed content of How to convert a date to a string using the current locale's conventions?. For more information, please follow other related articles on the PHP Chinese website!