Date对象

来源:互联网 发布:mac视频截取gif软件 编辑:程序博客网 时间:2024/05/23 13:02

<!DOCTYPE html>

<html>

<head>

<metacharset="UTF-8">

<title></title>

</head>

<body>

<scripttype="text/javascript">

// Date对象

// 记录时间,时间对象

varnow = new Date();

// alert(now);

// 年份获取

varyear = now.getFullYear();

// alert(year);


//月份获取 0 -11

varmonth = now.getMonth() + 1;

// alert(month);

// 日获取

varday = now.getDate();

// alert(day);

// 星期获取

varweekday = now.getDay();

// alert(weekday);

// 小时获取 24小时

varhour = now.getHours();

// alert(hour);

// 分钟获取

varminute = now.getMinutes();

// alert(minute);

// 秒获取

varsecond = now.getSeconds();

// alert(second);

// 毫秒获取

varmillisecond = now.getMilliseconds();

// alert(millisecond);


// 从1970年1月1日到现在的毫秒数

// 时间戳

vartime = now.getTime();

// alert(time);

// 获取到指定时间

varfuture = new Date(2017,0,2,8,30,60);

// alert(future);

</script>

</body>

</html>

0 0