|
#1
|
|||
|
|||
|
Hi all, can somebody help me to display the date as well as the time in "Local Time script"
http://www.dynamicdrive.com/dynamicindex6/localtime.htm 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! |
|
#2
|
||||
|
||||
|
Sure. To get the script to display the current full date as well, just replace the old function:
Code:
showLocalTime.prototype.updateContainer=function(){
"
"
}
Code:
showLocalTime.prototype.updateContainer=function(){
var thisobj=this
if (this.displayversion=="long")
this.container.innerHTML=this.localtime.toLocaleString()
else{
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
}
|
|
#3
|
|||
|
|||
|
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! |
|
#4
|
||||
|
||||
|
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:
Code:
<form> <input type="text" id="timecontainer" /> </form> |
|
#5
|
|||
|
|||
|
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...
|
|
#6
|
||||
|
||||
|
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?
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
|
|