Forum Moderators: phranque

Message Too Old, No Replies

How do I put today's date on my web page?

So that the date updates automatically

         

gabby

10:10 pm on Oct 22, 2004 (gmt 0)

10+ Year Member



Hi all, does anyone know of an application that will keep the date updated automatically on a web site.

I found a couple of Javascripts that would give a scroll at the bottom, but I am looking for somthing that will update the date in the body of the document.

Any suggestions?

Frank_Rizzo

10:23 pm on Oct 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



javascript will do that too. If you keep searching for javascript date script you should find a few places with the code.

There are some good ones out there which say 'good evening', 'good morning' etc.

Maybe you have seen a website which does exactly what you want. Have you viewed to the source to see how they do it?

I don't mean lift the code, but see if there is a 'script from xyzscripts' message.

skipfactor

11:00 pm on Oct 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For ASP, it's:

<%Response.Write Date%>

grandpa

1:53 am on Oct 23, 2004 (gmt 0)

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



This works for me...

Today's Date is&nbsp;
<script type="text/javascript" language="JavaScript">
var dateMod = "" ;
dateMod = new Date();
document.write((1 + dateMod.getMonth()) + "/" + (dateMod.getDate()) + "/" + dateMod.getFullYear());
</script>

<add>Place this script in the document body wherever you want the date displayed.</add>

coopster

7:50 pm on Oct 23, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, gabby.

JavaScript will work for those users that allow JavaScript to run in their browsers, otherwise you'll need a server-side solution such as an Apache include or perhaps a server-side scripting language as mentioned -- ASP, PHP, Perl, or some other scripting language.

Also, JavaScript will only show what the user's machine clock is set to, whereas the server-side solution you could always make sure it is serving up the correct time, even time zone specific, if you want to go that far.