Sep
18
Javascript 的时间日期处理(可以取得精确的时间,到毫秒级)
主要是对Date对象的使用。
测试一下:
转载请注明出自 ,如是转载文则注明原出处,谢谢:)
RSS订阅地址: https://www.felix021.com/blog/feed.php 。
测试一下:
<script language="javascript">
function showTime(){
var a=new Date();
var y = a.getFullYear()+"-";
var m = (a.getMonth()+1)+"-";
var d = a.getDate()+" ";
var h = a.getHours()+":";
var x = a.getMinutes()+":";
var s = a.getSeconds()+".";
var ms=a.getMilliseconds();
alert(y + m + d + h + x + s + ms);
}
//取得时间戳的办法(精确到毫秒):
function timestamp(){
var a = new Date();
return Date.parse(a) + a.getMilliseconds();
}
</script>
function showTime(){
var a=new Date();
var y = a.getFullYear()+"-";
var m = (a.getMonth()+1)+"-";
var d = a.getDate()+" ";
var h = a.getHours()+":";
var x = a.getMinutes()+":";
var s = a.getSeconds()+".";
var ms=a.getMilliseconds();
alert(y + m + d + h + x + s + ms);
}
//取得时间戳的办法(精确到毫秒):
function timestamp(){
var a = new Date();
return Date.parse(a) + a.getMilliseconds();
}
</script>
欢迎扫码关注:
转载请注明出自 ,如是转载文则注明原出处,谢谢:)
RSS订阅地址: https://www.felix021.com/blog/feed.php 。