PDA

View Full Version : get the current time



Ni3ls
26th March 2016, 08:59
Hi all,

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


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?

Whiskas
26th March 2016, 09:53
Isn't it time of your vps? Check date command in ssh client.

Ni3ls
26th March 2016, 14:46
Isn't it time of your vps? Check date command in ssh client.

Yes you are right. How can I fix this?

voron00
26th March 2016, 14:54
Yes you are right. How can I fix this?


sudo apt-get install ntpdate
sudo ntpdate -s time.nist.gov

Or just


date --set="23 June 1988 10:00:00"
date --set="10:00:00"

IzNoGoD
26th March 2016, 15:07
And if you're running on an openvz/docker/lxc vps: shout at your host to fix it.