Click to See Complete Forum and Search --> : Correct?
Jonathan
07-03-2003, 02:23 PM
Is this correct for a date that displays like so,
Todays date: June 3, 2003
<script language="JavaScript" type="text/javascript">
<!--
var d = new Date();
var monthName = new Array("January","Febuary","March","April","May","June","July","August","September","October","November","December");
var da = d.getDay() - 1;
var year = d.getFullYear();
var complete = (monthName[d.getMonth()]+ ", "+da+" "+year);
document.write("<B>Todays date: "+complete+ "</b>");
//-->
</script>
Originally posted by Jonathan
Is this correct for a date that displays like so,
Apparently so, I tested the code in IE6 and it works fine for me.
[J]ona
Charles
07-03-2003, 02:42 PM
Originally posted by Jona
Apparently so, I tested the code in IE6 and it works fine for me.
[J]ona Take a closer look; it will stop working this comming Sunday, 2003-07-06. Try instead:
<script type="text/javascript">
<!--
Date.prototype.toString = function () {return [[['January', 'Febuary', 'March', 'April', 'May', 'June', 'July' ,'August' ,'September' ,'October', 'November' ,'December'][this.getMonth()], this.getDate()].join(' '), this.getFullYear()].join(', ')}
document.write('<p>Today\\'s date: ', new Date(), '</p>')
//-->
</script>
Originally posted by Charles
Take a closer look; it will stop working this comming Sunday, 2003-07-06.
...Yeah, I did notice a few things, but I didn't look very closely or say anything... Sorry, Jonathan.
[J]ona
Jonathan
07-03-2003, 02:50 PM
Why will it stop working?
Charles
07-03-2003, 02:54 PM
Originally posted by Jonathan
Why will it stop working? Try this:
<script type="text/javascript">
<!--
var d = new Date('6 July 2003');
var monthName = new Array("January","Febuary","March","April","May","June","July","August","September","October","November","December");
var da = d.getDay() - 1;
var year = d.getFullYear();
var complete = (monthName[d.getMonth()]+ ", "+da+" "+year);
document.write("<B>Todays date: "+complete+ "</b>");
//-->
</script>
Jonathan
07-03-2003, 02:56 PM
I still dont get it... How can it work for just a few of the dates?