Forum Moderators: phranque

Message Too Old, No Replies

Time/date on my home page

         

specter

10:40 am on Dec 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi everyone,

I'm wondering for a simple way to install a time/date indicator on my web site home page;
Has anyone a good idea to suggest?

Thanks

txbakers

3:05 pm on Dec 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can use Javascript for this: document.write(now()) is the most basic way to add this.

Look up the Javascript Date functions to see other configurations.

specter

4:09 pm on Dec 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have I to add exactly this line:

document.write(now())
?

tbear

6:05 pm on Dec 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If your server has php functional you can add the following:
<?php print (Date("l, d F , Y"));?>

Terabytes

6:28 pm on Dec 26, 2005 (gmt 0)

10+ Year Member



...or a local solution

<script language=javascript1.1>
now = new Date();
day = new Object();
month = new Object();
day[0] = "Sunday";
day[1] = "Monday";
day[2] = "Tuesday";
day[3] = "Wednesday";
day[4] = "Thursday";
day[5] = "Friday";
day[6] = "Saturday";
month[0] = "Jan.";
month[1] = "Feb.";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "Aug.";
month[8] = "Sept.";
month[9] = "Oct.";
month[10] = "Nov.";
month[11] = "Dec.";
year = now.getYear();
if (year < 1000) year += 1900;
document.write(day[now.getDay()] + ", " + month[now.getMonth()] + " " + now.getDate() + ", " + year);
</script>

specter

10:19 pm on Dec 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Many thanks guys!

Sincerely

specter

5:49 pm on Dec 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



oops!

My clock doesn't work...

I copied the javascript code in my page but it appears as itself;
What am I missing?

Thanks

Terabytes

6:56 pm on Dec 27, 2005 (gmt 0)

10+ Year Member



I'm guessing that you copied the code snippet directly from the page and then pasted it into your favorite WYSIWYG Editor....

Copy the code from the page here, then paste it into something like notepad...

Copy the code from notepad and paste it into your editor...

Sometimes extra HTML comes along with text copied directly from the browser into WYSIWIG editors...

Pasting the code into notepad strips all the extranious garbage out...(formating, etc) and gives you just text...

try it...

specter

8:05 pm on Dec 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks again.
I'll let you know

specter

8:23 pm on Dec 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well!

It runs fine.
As I'm not properly a javascript geek,let me ask you a last couple of questions:

1)What for the time?
2)How can I show it on a single raw?

Sincerely

Terabytes

9:09 pm on Dec 27, 2005 (gmt 0)

10+ Year Member



that particular snippet grabs the time/date from the current system time..

(The time/date is taken from the computer that displays the web page it's on...)

If the users computer is wacked (IE date set to Sept 19, 1995) the time display will reflect that error also...

Tera