1
<script language="JavaScript">
2
//日期
3
var now = new Date(); //获取系统日期,即Sat Jul 29 08:24:48 UTC+0800 2006
4
var yy = now.getYear(); //截取年,即2006
5
var mm = now.getMonth(); //截取月,即07
6
var dd = now.getDay(); //截取日,即29
7
//取时间
8
var hh = now.getHours(); //截取小时,即8
9
var mm = now.getMinutes(); //截取分钟,即34
10
var ss = now.getTime() % 60000; //获取时间,因为系统中时间是以毫秒计算的,
11
所以秒要通过余60000得到。
12
ss = (ss - (ss % 1000)) / 1000; //然后,将得到的毫秒数再处理成秒
13
var clock = hh+':'; //将得到的各个部分连接成一个日期时间
14
if (mm < 10) clock += '0'; //字符串
15
clock += mm+':';
16
if (ss < 10) clock += '0';
17
clock += ss;
18
</script>

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18
