Click to See Complete Forum and Search --> : Time and date script.


Kobushi no Kami
04-26-2003, 10:18 PM
Hi. Is there a script to display time and date, the same your pc displays? I need help here, please. Thank u in advance.

Kobushi no Kami
04-26-2003, 10:40 PM
Yep, thanks so much

Charles
04-27-2003, 05:25 AM
You'll find though, that it doesn't work. There is no Date.toLocalString(); it's Date.toString(). And JavaScript will call it as necessary. (See http://developer.netscape.com/docs/manuals/js/client/jsref/date.htm.) But you will not like the resulting string so you might want to overwrite the method to your liking. If you just want the date:

<script type="text/javascript">
<!--
Date.prototype.toString = function () {return [['Sunday,', 'Monday,', 'Tuesday,', 'Wednesday,', 'Thursday,', 'Friday,', 'Saturday,'] [this.getDay()], this.getDate(), ['January', 'February', 'March', 'April', 'May', 'June', ,'July', 'August', 'September', 'October', 'November', 'December'] [this.getMonth()], this.getFullYear()].join('&nbsp;')}

document.write('<h6>', new Date(), '</h6>')
// -->
</script>

Charles
04-27-2003, 02:00 PM
The really sad thing is that I double checked the documentation and ran your example on a few different browsers. I must have been having a very bad morning.

Charles
04-27-2003, 05:54 PM
I think that I was having another bad morning. Thanks for catching my mistake. This, by the way, is why I refuse to offer back channel help.