Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert DATE & TIME into the webpage?

Status
Not open for further replies.

tyleri

Programmer
Jan 2, 2001
173
US
how can i write some simple code that grabs the date and time and displays it on the html page?
 
<html>
<head>
<script>
{
var current = Date();
document.write(current);
}
</script>
</head>
</html> [bomb]
I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
admin@onpntwebdesigns.com
 
that works - but i would like to have control over where it is placed...
 
<html>
<head>
<script>
function showit(){
var current = Date();
document.form1.text1.value = current;
}
</script>
</head>
<body onLoad=&quot;showit()&quot;>
<form name=&quot;form1&quot;>
<input type=&quot;text&quot; name=&quot;text1&quot;>
</form>
</body>
</html> [bomb]
I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
admin@onpntwebdesigns.com
 
that would only show you the time that the client computer has not the time the server has. In order to show the time of the server you will need to resort to server side technology. See the PHP forum. Gary Haran
 
I have a question refering to your post xutopia
would the server give up the time in the time zone the user is residing or the time zone the server is residing.
In the case it would not issue the correct time zone of the user then would it be more benificial to take the time from the users computer instead? [bomb]
I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
admin@onpntwebdesigns.com
 
I imagine it would be server time. But then again we have a choice now don't we! :)

I asked in the PHP forum if we could have the time according to the time zone of the client. We'll see what the answer is. Gary Haran
 
Thanks for the help - i have a problem -i'm already using the &quot;Onload&quot; function for something else in the body - also - it didnt' work anyway because i'm putting the time to default in a field in a form. help! aghahghagha
 
you can add as many functions to the onLoad as you want.
<body onLoad=&quot;show(); another(); andAnother()&quot;>

what do you mean it didn't work because i'm putting the time to default in a field in a form.

?????

[bomb]
I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
admin@onpntwebdesigns.com
 
Hi all,

If you want a really easy way to do this server side, then as long as you have SSI enabled you can use that.

<!--#config timefmt=&quot;%A %d %B %Y %T&quot; -->
<!--#echo var=&quot;DATE_LOCAL&quot; -->

But, as mentioned previously, this will show the time of the server and not the client. You can also show GMT time if you are outwith that time zone.

Hope this helps Wullie

sales@freshlookdesign.co.uk

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top