发布于 2017-01-31 12:34:31 | 174 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的Javascript教程,程序狗速度看过来!

JavaScript客户端脚本语言

Javascript 是一种由Netscape的LiveScript发展而来的原型化继承的基于对象的动态类型的区分大小写的客户端脚本语言,主要目的是为了解决服务器端语言,比如Perl,遗留的速度问题,为客户提供更流畅的浏览效果。


很多的新手朋友们对js中的时间格式与时间戳的转换比较陌生,下面就为大家详细介绍下具体的转换步骤,感兴趣的朋友可以参考下
一.时间转换时间戳
 
function transdate(endTime){ 
var date=new Date(); 
date.setFullYear(endTime.substring(0,4)); 
date.setMonth(endTime.substring(5,7)-1); 
date.setDate(endTime.substring(8,10)); 
date.setHours(endTime.substring(11,13)); 
date.setMinutes(endTime.substring(14,16)); 
date.setSeconds(endTime.substring(17,19)); 
return Date.parse(date)/1000; 
} 

二.时间戳转换时间
(1):转换成 2011-3-16 16:50:43 格式:
 
function getDate(tm){ 
var tt=new Date(parseInt(tm) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ") 
return tt; 
} 

(2):转换成 2011年3月16日 16:50:43:
 
function getDate(tm){ 
var tt=new Date(parseInt(tm) * 1000).toLocaleString() 
return tt; 
} 

(3):转换成 2011年3月16日 16:50
 
function getDate(tm){ 
var tt=new Date(parseInt(tm) * 1000).toLocaleString().substr(0,16); 
return tt; 
} 


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务