Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2003
    Location
    UK
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing script action from relative to server time

    I'm running a script with this instruction:

    Code:
    today = new Date()
    day = today.getDay()
    hr = today.getHours()
    min = today.getMinutes()
    if(min >= 30)hr +=.5;
    Is there a way of manipulating that code so the script action will occur according to the time on the server rather than as it is now?

  • #2
    New to the CF scene
    Join Date
    Aug 2006
    Location
    melbourne, aus
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well, i'm gonna assume you're using php
    Code:
    day = <?= date('d'); ?>;
    hr = <?= date('H'); ?>;
    min = <?= date('i'); ?>;
    if(min >= 30) {
    hr +=.5;
    }
    that will obviously run once, when the page is loaded, and give you the server time at load

    if you want to have the date/time constantly updated from the server, you will prolly need to look into xmlhttprequest i think, but i think once should be enough, you should be able to take the original time, and then just use javascript to change the time

    hth
    dave


  •  

    Posting Permissions

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