林熙越老婆,鲜网辣文合集,宫心计演员表
<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>
也可以这样写的
function formatdate(now) {
var year=now.getyear();
var month=now.getmonth()+1;
var date=now.getdate();
var hour=now.gethours();
var minute=now.getminutes();
var second=now.getseconds();
return year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second;
}
var d=new date(1230999938);
alert(formatdate(d));
好了问题解决
需要注意的是
不要把字符串中的date(这样的字符也传进去,要先处理一下,这样很方便 就能处理的
可以使用replace方法
如下:
replace("/date(","").replace(")/","");
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
网友评论