PDA

View Full Version : javascript date updating



rejean
04-13-2004, 06:21 AM
Hi everyone!
A friend of mine has the following script but the new update gives her 104 instead of 2004 for the year. How could she modify her script to make it work?
Thanks in advance.
Réjean

<script language="JavaScript">
function initArray()
{
this.length = initArray.arguments.length
for (var i=0;i<this.length;i++)
this[i+1] = initArray.arguments[i]
} // end initArray.

var DOWArray = new initArray("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var MOYArray = new initArray("January", "February", "March", "April", "May", "June", "July", "August","September", "October", "November", "December");
var LastModDate = new Date(document.lastModified);
document.write("&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I first published my site February 17, 2004.&nbsp;&nbsp;&nbsp <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;I last updated on");
document.write(DOWArray[(LastModDate.getDay()+1)],", ");
document.write(MOYArray[(LastModDate.getMonth()+1)]," ");
document.write(LastModDate.getDate(),", ",LastModDate.getYear());
document.write(".<P>");

</script>




</td>
</tr></body>
</html>

rejean
04-13-2004, 09:47 AM
Hi again!
I went and checked my friend's site with IE 6.0 and the script seems to be working fine. The problem appears when using Netscape 6.0, Mozilla 1.7 or Firefox 0.8. If that can help!
Thanks in advance,
Réjean

steve_skelton
05-19-2004, 02:26 PM
Hi everyone!
A friend of mine has the following script but the new update gives her 104 instead of 2004 for the year. How could she modify her script to make it work?
Thanks in advance.
Réjean

you can get your solution here:
http://tech.irt.org/articles/js199/index.htm

I recommend using the y2K function as this will work on the widest range of browsers.