<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>获得年份 </title>
<script type="text/javascript">
var mydate=new Date();
var myyear=mydate.getFullYear();
document.write("年份:"+myyear);
document.write(mydate.setFullYear(1994));
</script>
</head>
<body>
</body>
</html>
输出结果为:年份2017763224290162
明白了,谢谢
var mydate=new Date();
var myyear=mydate.getFullYear();
mydate.setFullYear(1994);
document.write("年份:"+myyear+"<br>");
document.write(mydate);
that's ok
mydate.setFullYear(1994),修改年份,但是要输出mydate,而不是年。