Results 1 to 5 of 5

Thread: get the current time

  1. #1
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts

    get the current time

    Hi all,

    Im trying to work with mysql and stuff and came across this post by izno

    Code:
    foo() 
    { 
        asyncQuery("SELECT NOW() AS `time`", ::showTime); 
    }
    
    showTime(rows, args) 
    { 
       if(isDefined(rows) && isDefined(rows[0]) && isDefined(rows[0]["time"])) 
          iprintlnbold("It is " + rows[0]["time"]); 
    }
    It does work, however the time is incorrect.
    I live in the Netherlands (GMT +1), tested it at 10:58, but time shows 10:15.
    What time does it show?

  2. #2
    Private Whiskas's Avatar
    Join Date
    Jan 2015
    Posts
    84
    Thanks
    69
    Thanked 20 Times in 17 Posts
    Isn't it time of your vps? Check date command in ssh client.

  3. The Following User Says Thank You to Whiskas For This Useful Post:

    Ni3ls (26th March 2016)

  4. #3
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Quote Originally Posted by Whiskas View Post
    Isn't it time of your vps? Check date command in ssh client.
    Yes you are right. How can I fix this?

  5. #4
    Corporal voron00's Avatar
    Join Date
    Nov 2014
    Posts
    248
    Thanks
    64
    Thanked 216 Times in 116 Posts
    Quote Originally Posted by Ni3ls View Post
    Yes you are right. How can I fix this?
    PHP Code:
    sudo apt-get install ntpdate
    sudo ntpdate 
    -s time.nist.gov 
    Or just

    PHP Code:
    date --set="23 June 1988 10:00:00"
    date --set="10:00:00" 
    Last edited by voron00; 26th March 2016 at 14:57.
    sudo apt-get rekt

  6. #5
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    And if you're running on an openvz/docker/lxc vps: shout at your host to fix it.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

Posting Permissions

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