Wednesday, July 1, 2009

Display the Local date

The following JavaScript Code snippet is used to display the Local date.
/* This function displays the date in Format */
/*For Today it will display Wednesday 1 Jul 2009


function getLocalDate()
{
var now = new Date();
var day = now.getDay();
var date = now.getDate();
var month = now.getMonth();
var year = now.getFullYear();

var DOW=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

var MON=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

return DOW[day] + ' ' + date + ' ' + MON[month] + ' ' + year; }


SAMPLE USAGE

< face="Tahoma" size="1" color="#ffffff">
< language="javascript">
document.write(getLocalDate());
< /script >
< /font >


OUPUT
Wednesday 1 Jul 2009

No comments:

Post a Comment