Go Back   Dynamic Drive Forums > DD Scripts > Dynamic Drive scripts help
Search Dynamic Drive Forums:

Reply
 
Thread Tools Search this Thread
  #1  
Old 11-29-2005, 07:57 PM
jasper77 jasper77 is offline
New Comer (less than 5 posts)
 
Join Date: Nov 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Local Time - date display?

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!
Reply With Quote
  #2  
Old 11-29-2005, 10:12 PM
ddadmin's Avatar
ddadmin ddadmin is offline
Administrator
 
Join Date: Aug 2004
Posts: 7,627
Thanks: 2
Thanked 639 Times in 629 Posts
Blog Entries: 13
Default

Sure. To get the script to display the current full date as well, just replace the old function:


Code:
 showLocalTime.prototype.updateContainer=function(){ 
"
"
}
inside the script with the below version instead:

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
}
Reply With Quote
  #3  
Old 11-29-2005, 10:44 PM
jasper77 jasper77 is offline
New Comer (less than 5 posts)
 
Join Date: Nov 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thank you very much.

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!
Reply With Quote
  #4  
Old 11-30-2005, 08:18 AM
ddadmin's Avatar
ddadmin ddadmin is offline
Administrator
 
Join Date: Aug 2004
Posts: 7,627
Thanks: 2
Thanked 639 Times in 629 Posts
Blog Entries: 13
Default

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>
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.
Reply With Quote
  #5  
Old 11-30-2005, 09:07 PM
jasper77 jasper77 is offline
New Comer (less than 5 posts)
 
Join Date: Nov 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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...
Reply With Quote
  #6  
Old 12-01-2005, 09:26 AM
ddadmin's Avatar
ddadmin ddadmin is offline
Administrator
 
Join Date: Aug 2004
Posts: 7,627
Thanks: 2
Thanked 639 Times in 629 Posts
Blog Entries: 13
Default

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?
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:58 AM.

Home - Contact Us - Archives - Link to DD - Top 

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.