js Date() 时间函数处理 关于 toLocaleDateString()


 

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

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

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

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

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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM