tolocalestring 方法依赖于格式化日期的底层操作系统。它使用运行脚本的操作系统的格式约定将日期转换为字符串。例如,在美国,月份出现在日期之前 (04/15/98),而在德国,日期出现在月份之前 (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>
以上就是如何使用当前区域设置的约定将日期转换为字符串?的详细内容。
