描述
Javascript date.toLocaleFormat() 方法使用指定的格式将日期转换为字符串。
注意 − 此方法可能不兼容所有浏览器。
语法
它的语法如下 -
Date.toLocaleFormat()
参数
- formatString − 与 C 语言中的 strftime() 函数所期望的格式相同的格式字符串。
返回值
返回格式化的日期。
例请尝试以下示例。
<html>
<head>
<title>JavaScript toLocaleFormat Method</title>
</head>
<body>
<script type = "text/javascript">
var dt = new Date(1993, 6, 28, 14, 39, 7);
document.write( "Formated Date : " + dt.toLocaleFormat( "%A, %B %e, %Y" ) );
</script>
</body>
</html>
输出
Formated Date : Wed Jul 28 1993 14:39:07 GMT+0530 (India Standard Time)