这个在php+mssql(日期类型为datetime)+ajax的时候才能用到,js需要把时间戳转为为普通格式,一般的情况下可能用不到
?
<script>
function getLocalTime(nS) {
return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
}
alert(getLocalTime(1293072805));
</script>
?
弹出
2010年12月23日 10:53
也可以用:
?
<script>
function getLocalTime(nS) {
return new Date(parseInt(nS) * 1000).toLocaleString().substr(0,17)}
alert(getLocalTime(1293072805));
</script>
?
如果想弹出:2010-10-20 10:00:00这个格式的也好办
?
<script>
function getLocalTime(nS) {
return new Date(parseInt(nS) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
}
alert(getLocalTime(1177824835));
</script>
?
1 楼
faroasis
2011-01-06
toLocale之类的方法在ie下取决于本地设置,不建议用来做展示之外的操作
另外firefox的tolocale方法实现是与ie不同的,貌似与本地设置无关
其他浏览器不了解
另外firefox的tolocale方法实现是与ie不同的,貌似与本地设置无关
其他浏览器不了解