FacebookTwitter
Hatrack River Forum   
my profile login | search | faq | forum home

  next oldest topic   next newest topic
» Hatrack River Forum » Active Forums » Books, Films, Food and Culture » Javascript -- Fugu?

   
Author Topic: Javascript -- Fugu?
Farmgirl
Member
Member # 5567

 - posted      Profile for Farmgirl   Email Farmgirl         Edit/Delete Post 
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

Posts: 9538 | Registered: Aug 2003  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
code:
<script language="Javascript">
<!--
today = new Date();
document.write(today.toLocaleString());
//-->
</script>

Where you want the date to appear.
Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Miro
Member
Member # 1178

 - posted      Profile for Miro   Email Miro         Edit/Delete Post 
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?
Posts: 2149 | Registered: Aug 2000  |  IP: Logged | Report this post to a Moderator
Dagonee
Member
Member # 5818

 - posted      Profile for Dagonee           Edit/Delete Post 
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

Posts: 26071 | Registered: Oct 2003  |  IP: Logged | Report this post to a Moderator
Farmgirl
Member
Member # 5567

 - posted      Profile for Farmgirl   Email Farmgirl         Edit/Delete Post 
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

Posts: 9538 | Registered: Aug 2003  |  IP: Logged | Report this post to a Moderator
Dagonee
Member
Member # 5818

 - posted      Profile for Dagonee           Edit/Delete Post 
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"
Posts: 26071 | Registered: Oct 2003  |  IP: Logged | Report this post to a Moderator
Farmgirl
Member
Member # 5567

 - posted      Profile for Farmgirl   Email Farmgirl         Edit/Delete Post 
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

Posts: 9538 | Registered: Aug 2003  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
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.
Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
*bump* so farmgirl sees.
Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
Farmgirl
Member
Member # 5567

 - posted      Profile for Farmgirl   Email Farmgirl         Edit/Delete Post 
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

Posts: 9538 | Registered: Aug 2003  |  IP: Logged | Report this post to a Moderator
fugu13
Member
Member # 2859

 - posted      Profile for fugu13   Email fugu13         Edit/Delete Post 
Not a problem. Javascript's not my favorite language, but it has its uses [Smile] .
Posts: 15770 | Registered: Dec 2001  |  IP: Logged | Report this post to a Moderator
   

   Close Topic   Feature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:


Contact Us | Hatrack River Home Page

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