JavaScript时间格式转换总结.
2011-12-26 09:42
429 查看
1.当前系统区域设置格式(toLocaleDateString和toLocaleTimeString)
例子:
(new Date()).toLocaleDateString() + + (new Date()).toLocaleTimeString()
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
结果: 2008年1月29日 16:13:11
2.普通字符串(toDateString和toTimeString)
例子: (new Date()).toDateString() + + (new Date()).toTimeString()
结果:Tue Jan 29 2008 16:13:11 UTC+0800
3.格林威治标准时间(toGMTString)
例子: (new Date()).toGMTString()
结果:Tue, 29 Jan 2008 08:13:11 UTC
4.全球标准时间(toUTCString)
例子: (new Date()).toUTCString()
结果:Tue, 29 Jan 2008 08:13:11 UTC
5.Date对象字符串(toString)
例子: (new Date()).toString()
结果:Tue Jan 29 16:13:11 UTC+0800 2008
相关文章推荐
- JavaScript时间格式转换总结
- JavaScript 时间 格式 转换 及 Date对象 总结
- JavaScript时间格式转换总结
- JavaScript 时间 格式 转换 及 Date对象 总结
- JavaScript 时间、格式、转换及Date对象总结
- JavaScript 时间、格式、转换及Date对象总结
- JavaScript时间格式转换总结
- JavaScript 时间、格式、转换及Date对象总结
- IOS 时间格式 时间转换 大总结
- IOS 时间格式 时间转换 大总结
- iOS 时间格式 时间转换 大总结
- java中字符串转换成时间格式总结
- IOS 时间格式 时间转换 大总结
- javaScript中将时间戳转换成日期格式
- IOS 时间格式 时间转换 大总结
- JavaScript时间戳转换正常时间格式
- iOS时间格式转换总结
- java中字符串转换成时间格式总结
- 下面总结一下js中时间戳与日期格式的相互转换:
- 把json格式的字符串转换成javascript对象或数组的方法总结