学习笔记--js的date对象

在js中获取当前时间

<script type="text/javascript">
var date=new Date();
document.write(date.toLocaleString());
document.write("<hr>");
document.write(date);
</script>

**获取当前年的方法

getFullYear();

**获取当前月的方法

getMoth():返回的是0-11月,如果想得到准确得知,加1

var date1=date.getMoth()+1;

document.write("moth"+date1);

**获取当前星期

getDay():星期,返回的是(0——6)

 

posted on 2016-03-18 17:54  ShamSilence  阅读(129)  评论(0)    收藏  举报

导航