Click to See Complete Forum and Search --> : Where did the time go ?


Kaisa
05-20-2003, 04:02 AM
How do i put a text clock on my website without anything around it for free and that i can also change the colors of it :p

Tim158
05-20-2003, 05:39 AM
Here is a great resource that should have a clock that you are looking for:

http://javascript.internet.com/clocks/

I'm sure nobody would mind if you just left the comments in the source code to show where you got it from... or just change it enough so it becomes your own script.

Tim

Charles
05-20-2003, 06:17 AM
<script type="text/javascript">
<!--
Date.ONE_SECOND = 1000;
Date.ONE_MINUTE = Date.ONE_SECOND * 60;

Date.prototype.toTimeString = function () {
var HOURS = ['', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve'];
var MINUTES = ['o\\'clock', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', 'twenty-one', 'twenty-two', 'twenty-three', 'twenty-four', 'twenty-five', 'twenty-six', 'twenty-seven', 'twenty-eight', 'twenty-nine', 'thirty', 'thirty-one', 'thirty-two', 'thirty-three', 'thirty-four', 'thirty-five', 'thirty-six', 'thirty-seven', 'thirty-eight', 'thirty-nine', 'forty', 'forty-one', 'forty-two', 'forty-three', 'forty-four', 'forty-five', 'forty-six', 'forty-seven', 'forty-eight', 'forty-nine', 'fifty', 'fifty-one', 'fifty-two', 'fifty-three', 'fifty-four', 'fifty-five', 'fifty-six', 'fifty-seven', 'fifty-eight', 'fifty-nine', 'sixty'];

return ['Current time: ', HOURS[this.getHours() > 12 ? this.getHours() - 12 : this.getHours()], MINUTES[this.getMinutes()]].join(' ')}

document.write('<p id="time">', new Date().toTimeString(), '</p>');

if (document.getElementById) setInterval("document.getElementById('time').replaceChild(document.createTextNode (new Date().toTimeString()), document.getElementById('time').firstChild)", 0.2 * Date.ONE_MINUTE);

// -->
</script>

Kaisa
05-20-2003, 07:32 AM
Why all those words ?

Charles
05-20-2003, 10:43 AM
Originally posted by Kaisa
Why all those words ? Is that not what you ment by 'text clock'?

Nevermore
05-20-2003, 12:03 PM
I think by text-clock he just meant using text numbers, not pictures of numbers. I like clocks like Charles', though...