View Full Version : Local Time - date display?

11-29-2005, 07:57 PM
Hi all, can somebody help me to display the date as well as the time in "Local Time script"


The script shows: // Current New York Time: 19:54:44 (Tues) //

How can I display this for example: 19:54:44 (29-11-2005 - Tues)

with SSI ot PHP no mather my server support them both.

Thank you!

11-29-2005, 10:12 PM
Sure. To get the script to display the current full date as well, just replace the old function:


inside the script with the below version instead:

var thisobj=this
if (this.displayversion=="long")
var hour=this.localtime.getHours()
var minutes=this.localtime.getMinutes()
var seconds=this.localtime.getSeconds()
var ampm=(hour>=12)? "PM" : "AM"
var currentdate=this.localtime.getDate()+"-"+(this.localtime.getMonth()+1)+"-"+this.localtime.getFullYear()
var dayofweek=weekdaystxt[this.localtime.getDay()]
this.container.innerHTML=formatField(hour, 1)+":"+formatField(minutes)+":"+formatField(seconds)+" "+ampm+" ("+currentdate+" - "+dayofweek+")"
setTimeout(function(){thisobj.updateContainer()}, 1000) //update container every second

11-29-2005, 10:44 PM
Thank you for your help Admin, yes it works with span id, div id... but I can't get it to work inside a text field value. Say for example I'm updating some info in my page and every time I click save, I want to have a text field like:
<input type="text" id="timecontainer" name="timecontainer" value='local time here'> so i can see when I have updated this info.

If you have this: <input type="text" id="timecontainer" name="timecontainer" value=' '> you will see the time inside the text field, but it is not in the ( value=' ' ) so when you click SAVE the text field is empty.

- How can I display inside the ( value=' ' )?

Many thanks!

11-30-2005, 08:18 AM
Well, to get the script to display itself inside a <input> field, simply replace all occurences of "innerHTML" inside the script with "value" instead (there should be two of them). Then create a form such as:

<input type="text" id="timecontainer" />

where "timecontainer" is the ID of the form field to show the date. I'm not sure if this answers your question, as what you're asking seems to be more specific.

11-30-2005, 09:07 PM
Thanks for your response Admin, but this isn't working, this is what i said above that it show the time inside the field, but is not in the (value='is empty') section...

12-01-2005, 09:26 AM
Hmmm if you see the local time in the <input> field, it means its "value" attribute has been changed. It should also mean that when you submit the form, the local time gets submitted as well. I don't see why this wouldn't be the case unless there is something malfunctioning with your form submit script?