toLocaleDateString()方法的真正含义为「根据本地时间把Date对象的日期部分转换为字符串」,这意味着:在不同的浏览器或者服务器中,我们可能得到不同的字符串。

例如,将 Chrome 浏览器的版本从57升级为58再升级为69,通过toLocaleDateString()方法获取的时间字符串格式分别为:

#Chrome =
> new Date().toLocaleDateString()
> output: "2018/9/28" #Chrome =
> new Date().toLocaleDateString()
> output: "2018-9-28" #Chrome =
> new Date().toLocaleDateString()
> output: "9/28/2018"

js Date() 时间函数处理 关于 toLocaleDateString()的更多相关文章

  1. js Date 时间格式化的扩展

    js Date 时间格式化的扩展: Date.prototype.format = function (fmt) { var o = { , //月 "d+": this.getD ...

  2. date时间函数

    时间函数: date();和time();的相互转换 time();   在PHP中单位是秒,在js中是毫秒. microtime();  毫秒 date('Y-m-d H:i:s',time()); ...

  3. JS Date.parse() 函数详解

    Date.parse()函数用于分析一个包含日期的字符串,并返回该日期与 1970 年 1 月 1 日午夜之间相差的毫秒数. 该函数属于Date对象,所有主流浏览器均支持该函数. 语法 Date.pa ...

  4. js日期时间函数

    日期时间脚本库方法列表 Date.prototype.isLeapYear 判断闰年Date.prototype.Format 日期格式化Date.prototype.DateAdd 日期计算Date ...

  5. 关于JS Date 时间计算

    倒计时功能Demo:http://play.163.com/special/test-timeending/?1465197963677 获取时间 Date() 返回当日的日期和时间. getDate ...

  6. js Date()日期函数浏览器兼容问题解决方法

    一般 直接new Date() 是不会出现兼容性问题的,而 new Date(datetimeformatstring) 常常会出现浏览器兼容性问题,为什么,datetimeformatstring中 ...

  7. js 月历 时间函数 月份第一天 星期的判断

    返回值为0-6,其中返回值0为星期天:如同,php中的日期函数一样判断.

  8. JS Date 时间格式化

    Date2Str(x, y) { , d: x.getDate(), h: x.getHours(), m: x.getMinutes(), s: x.getSeconds() }; y = y.re ...

  9. php函数strtotime结合date时间修饰语的使用

    下面简单介绍在项目开发中date时间函数和strtotime所遇到的问题,以及解决办法. 原文地址:小时刻个人技术博客 > http://small.aiweimeng.top/index.ph ...

随机推荐

  1. python字符串、列表、元组

    字符串的常用方法: name.count('h')统计h在name中出现的次数 name.find('h')查找h的索引 '?'.join(name)使用问好拼接 name.encode('gb231 ...

  2. luoguP4921 情侣?给我烧了! 组合数_容斥原理_计数问题

    Code: #include <cstdio> #include <algorithm> #include <cstring> #define setIO(s) f ...

  3. UVA10082-WERTYU(紫书例题3.2)

    A common typing error is to place the hands on the keyboard one row to the right of the correct posi ...

  4. CF1027F Session in BSU (并查集+树上构造)

    题目大意:你可以在第$ai$天或者第$bi$天进行第$i$场考试,每天最多进行一场考试,求把所有考试都考完的最早结束时间 由于天数可能很大,需要离散 把问题抽象成一棵树,每个点最多被"分配& ...

  5. SA 学习笔记

    后缀数组是解决字符串问题的有力工具--罗穗骞 后缀数组是对字符串的后缀排序的一个工具, sa将排名为i的字符串的开头位置记录下来, rnk将开头位置为i的字符串的排名记录下来. https://www ...

  6. 转载一遍比较好的,django2.1搭建博客教程

    非常感谢这位博主,找了几个星期终于找到了 https://www.dusaiphoto.com/article/article-detail/4/

  7. oracle截取某一个字符之前或之后的值;substr();instr()

    函数介绍: 截取的函数: substr(?,?); substr(?,?,?); 获取目标字符出现的位置: instr(? , ? , ? ); instr( ? , ? , ? , ? ) 例: 字 ...

  8. onkeydown、onkeypress、onkeyup、onblur、onchange、oninput、onpropertychange的区别

    onkeydown:按下任何键(字母.数字.系统.tab等)都能触发,且对于字母不区分大小写: onkeypress:按下字母.数字键时触发,且对于字母区分大小写; onkeyup:相应的键和onke ...

  9. js中“原生”map

    var map = {}; // Map map = new HashMap(); map[key] = value; // map.put(key, value); var value = map[ ...

  10. Servlet里面一调用Dao里的某个方法

    背景: 这几天,由于项目集成的需要,我要在doFilter里调用dao层里的某些方法,可是总之报空指针,只要调用那个dao方法,就报错误.很是纳闷,网上查找了各种原因,终于让我给突破了,看来还是Jav ...