Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Local Time

  1. #1
    Join Date
    Dec 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Local Time

    http://www.dynamicdrive.com/dynamicindex6/localtime.htm

    Sorry for the question... I am quite new using this technology...My question is conserning the script you have with the local time... somewhere it says that works only "with SSI ot PHP"

    I have tested saving the file as shtml and it works like a charm. But then i try to save it as asp file does not work... is there any way to include the shtml file in a asp file in order to present it properly in my site???

    Sorry if my question is quite irrelevant

    thank you
    Last edited by spinoza; 12-05-2005 at 07:42 AM.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Warning: Please include a link to the DD script in question in your post. See this thread for the proper posting format for asking a question.

    The script as is requires that your page either by SSI (.shtml) or PHP (.php) enabled. ASP won't do, but only because I'm not familiar with the syntax needed to output the current date in ASP. If anyone knows how, I'm sure the script can easily be modified for ASP pages as well.

    I'll do a search online as soon as I have the time.

  3. #3
    Join Date
    Dec 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi all,

    Has anyone use this script with asp page??. I would be very grateful if you could share this information.

    Gracias

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Ok, I did some research, and have modified the script to support ASP pages as well: http://www.dynamicdrive.com/dynamicindex6/localtime.htm Mainly, just replace the code of Step 1 with the new version, then use "server-asp" as the keyword to pass into showLocalTime() to indicate your page is ASP.

  5. #5
    Join Date
    Dec 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ddadmin thank you very much for your response...but it seems that does not work...

    it appears like this

    Current Server Time:NaN:NaN:NaN AM (undefined)
    Current LA Time:NaN:NaN:NaN AM (undefined)
    Current New York Time:NaN:NaN:NaN AM (undefined)


    the code i use is the following

    <html>
    <head>
    <script type="text/javascript">

    /***********************************************
    * Local Time script- © Dynamic Drive (http://www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for this script and 100s more.
    ***********************************************/

    var weekdaystxt=["Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"]

    function showLocalTime(container, servermode, offsetMinutes, displayversion){
    if (!document.getElementById || !document.getElementById(container)) return
    this.container=document.getElementById(container)
    this.displayversion=displayversion
    var servertimestring=(servermode=="server-php")? '<? print date("F d, Y H:i:s", time())?>' : (servermode=="server-ssi")? '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->' : '<%= Now() %>'
    this.localtime=this.serverdate=new Date(servertimestring)
    this.localtime.setTime(this.serverdate.getTime()+offsetMinutes*60*1000) //add user offset to server time
    this.updateTime()
    this.updateContainer()
    }

    showLocalTime.prototype.updateTime=function(){
    var thisobj=this
    this.localtime.setSeconds(this.localtime.getSeconds()+1)
    setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second
    }

    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 dayofweek=weekdaystxt[this.localtime.getDay()]
    this.container.innerHTML=formatField(hour, 1)+":"+formatField(minutes)+":"+formatField(seconds)+" "+ampm+" ("+dayofweek+")"
    }
    setTimeout(function(){thisobj.updateContainer()}, 1000) //update container every second
    }

    function formatField(num, isHour){
    if (typeof isHour!="undefined"){ //if this is the hour field
    var hour=(num>12)? num-12 : num
    return (hour==0)? 12 : hour
    }
    return (num<=9)? "0"+num : num//if this is minute or sec field
    }

    </script>

    </head>

    <body>

    Current Server Time:<span id="timecontainer"></span><br />
    Current LA Time:<span id="timecontainer2"></span><br />
    Current New York Time:<span id="timecontainer3"></span><br />

    <script type="text/javascript">
    new showLocalTime("timecontainer", "server-asp", 0, "short")
    new showLocalTime("timecontainer2", "server-asp", -60, "short")
    new showLocalTime("timecontainer3", "server-asp", 120, "short")
    </script>

    </body>

    </html>

    Ami doing something wrong???

  6. #6
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    It looks right. Are you sure the page you're putting this script on is ASP enabled? Here's an example I uploaded onto a ASP host that shows the script working: http://d.1asphost.com/georgecc/time.asp

  7. #7
    Join Date
    Dec 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    quite strange....could u please upload here the script of the page you used in your above post???

    I cant understand whats going on....

  8. #8
    Join Date
    Dec 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ok...i went to file---> view source...copy paste the code... and guess what...

    it is playing like a charm....

    Gracias....Gracias... Gracias

  9. #9
    Join Date
    Dec 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    well, I tested with Opera browser and plays well ... but with IE I realise now that it doesnt work at all... any idea why is this could happen???

    Quite strange isn't it?

  10. #10
    Join Date
    Dec 2005
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    well you can see it here... www.spinoza.gr ....go to the bottom of the page...if you have opera as i said before you will see that it plays

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •