This is topic Javascript -- Fugu? in forum Books, Films, Food and Culture at Hatrack River Forum.


To visit this topic, use this URL:
http://www.hatrack.com/ubb/main/ultimatebb.php?ubb=get_topic;f=2;t=023359

Posted by Farmgirl (Member # 5567) on :
 
Fugu and all you other webmasters out there.

Where can I find a bit of javascript (or whatever it takes) that will update the date on my page daily?

Currently, my departmental web page (this is in-house, our company) at the top I have:

quote:
Current Network Status:
Monday, April 12, 2004

Each day I have to manually updated that blasted day/date line (to Tuesday, April 13, 2004, etc).

I'm sure there has got to be some script that could automatically update it, but I don't know where to find said script. I know HTML, but don't know javascript.

Farmgirl
 
Posted by fugu13 (Member # 2859) on :
 
code:
<script language="Javascript">
<!--
today = new Date();
document.write(today.toLocaleString());
//-->
</script>

Where you want the date to appear.
 
Posted by Miro (Member # 1178) on :
 
Just a question: Where does it get the date from? Will someone accessing the site in Australia see a different date than someone in the US?
 
Posted by Dagonee (Member # 5818) on :
 
I believe fugu's sample is client-side, so the date comes from the browser machine. Which means it's tomorrow in Australia.

The other way to handle it would be a PHP or other script (ASP, etc.) to insert the date server-side. I can provide a sample if I know what the platform is.

Dagonee
 
Posted by Farmgirl (Member # 5567) on :
 
I want it to be client-side, so that would work well. I need it to pull the date from the host server, which is also an internal server.

I haven't tried this yet, Fugu, but does it pull the DAY title (Monday, Tuesday, Wednesday) as well as the date?

Farmgirl
 
Posted by Dagonee (Member # 5818) on :
 
This HTML page:

code:
<HTML>
<BODY>
<script language="Javascript">
<!--
today = new Date();
document.write(today.toLocaleString());
//-->
</script>
</BODY>
</HTML>

displays "Monday, April 12, 2004 2:31:24 PM"
 
Posted by Farmgirl (Member # 5567) on :
 
Yes, I put it in there now, and it looks great. I didn't necessarily want the time, but now that I have it, I guess I don't mind. Usually I only note the time on the page when we have a network issue -- to let them know what time the last network status update was.

Thanks so much!

Farmgirl
 
Posted by fugu13 (Member # 2859) on :
 
To have just the date:

code:
<script language="Javascript">
<!--
today = new Date();
document.write(today.toLocaleDateString());
//-->
</script>

Should be almost exactly the format you wrote it in, actually, though its somewhat locale specific.
 
Posted by fugu13 (Member # 2859) on :
 
*bump* so farmgirl sees.
 
Posted by Farmgirl (Member # 5567) on :
 
yeah -- I saw it this morning (went looking). I haven't change it, though -- because I kinda LIKE the time now that it is there.

However, another guy in another department liked the original code you shared, and he doesn't want the time, so I will let him know.

I had to re-read it three or four times to figure out the difference between the original code you gave me and the new one. (I'm blind, I guess)

Thanks so much, Russ
Farmgirl
 
Posted by fugu13 (Member # 2859) on :
 
Not a problem. Javascript's not my favorite language, but it has its uses [Smile] .
 


Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2