直接上代码:
- <script type="text/javascript">
- var minutes = 1000*60
- var hours = minutes*60
- var days = hours*24
- var years = days*365
- var d = new Date()
- var t = d.getTime()
- var y = t/years
- document.write(parseInt(y)+"<br />");
- document.write(new String(""+y).split("\.")[0]+"<br />");
- document.write(new String(y).split("\.")[0]+"<br />");
- document.write(new String(y).split(".")[0]+"<br />");
- document.write(Math.floor(y)+"<br />");
- document.write(Math.ceil(y)+"<br />");
- </script>
结果:
42
42
42
42
42
43