Sunday 27 July 2008

Print Current Year Using JavaScript

I wanted to be able to print the current year in an HTML document, so I came up with this line of JavaScript code to do the job.



   1:<script type="text/javascript">var today=new Date();
2:document.write(today.getFullYear());</script>


Here is the code for cutting and pasting.



<script type="text/javascript">var today=new Date(); document.write(today.getFullYear());</script>

No comments:

Post a Comment