• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • Date.prototype.toDateString()

    toDateString()方法以美式英语和人类易读的形式返回一个日期对象日期部分的字符串。

    语法

    dateObj.toDateString()
    

    描述

    SpiderMonkey 里,该字符串由日期部分(年月日)和其后的时间部分(时分秒及时区)组成。有时需要获取日期部分的字符串,这可以由toDateString方法完成。

    The toDateString method is especially useful because compliant engines implementing ECMA-262 may differ in the string obtained from toString for Date objects, as the format is implementation-dependent and simple string slicing approaches may not produce consistent results across multiple engines.

    例子

    例子:toDateString方法的简单使用

    var d = new Date(1993, 6, 28, 14, 39, 7);
    
    println(d.toString());     // prints Wed Jul 28 1993 14:39:07 GMT-0600 (PDT)
    println(d.toDateString()); // prints Wed Jul 28 1993