JavaScript中的Date.toString()函数
Date对象是JavaScript语言中内置的数据类型。日期对象使用新的Date()创建,如下所示。
创建Date对象后,可以使用多种方法对其进行操作。大多数方法仅允许您使用本地时间或UTC(通用或GMT)时间来获取和设置对象的年,月,日,时,分,秒和毫秒字段。
toString()日期对象的功能返回日期对象的字符串表示形式。
语法
它的语法如下
dateObj.toString()
请尝试以下示例。
示例
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script type="text/javascript">
var dateObj = new Date('September 26, 89 12:4:25:96');
document.write("Current Date: "+dateObj.toString());
</script>
</body>
</html>输出结果
Current Date: Tue Sep 26 1989 12:04:25 GMT+0530 (India Standard Time)
请尝试以下示例。
示例
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script type="text/javascript">
var dateObj = new Date();
document.write("Current Date: "+dateObj.toString());
</script>
</body>
</html>输出结果
Current Date: Thu Oct 18 2018 15:20:42 GMT+0530 (India Standard Time)
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下