Wednesday, 29 April 2009

Javascript Function to Return the Day of the Year

This simple Javascript function returns the day of the year.



<script type="text/javascript">

function dayOfYear()
var firstJan = Math.floor((new Date().setFullYear(new Date().getFullYear(),0,1))/86400000);
var today = Math.ceil((new Date().getTime())/86400000);




<h1>Day of Year</h1>

Today is day <script type="text/javascript">document.write(dayOfYear());</script> of the year.



Today is day of the year.

No comments: