MySQL Showing wrong date

furquan

Well-Known Member
Jul 27, 2002
473
4
168
Hello all,

Today a client of mine came over saying my servers MySQL is showing him the wrong date when he runs this function :-


mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2012-07-25 22:49:03 |
+---------------------+
1 row in set (0.00 sec)

Can any one tell me, how can i go ahead and rectify this issue ?

Thank you,
 

CitizenK

Well-Known Member
Jun 5, 2012
64
1
58
On The Road
cPanel Access Level
Root Administrator
Hello,

Can you please run the date command from ssh and let us know if that is showing the wrong date too. If it is you can use the command below to manually set a date.

# date MMDDhhmmYYYY

You can also sync your clock using an internet time sync server in WHM >> Server Configuration >> Server Time


Thanks,
 

furquan

Well-Known Member
Jul 27, 2002
473
4
168
This is what I get :-

[email protected] [~]# date MMDDhhmmYYYY
date: invalid date `MMDDhhmmYYYY'
 

CitizenK

Well-Known Member
Jun 5, 2012
64
1
58
On The Road
cPanel Access Level
Root Administrator
You have to replace the letters into their corresponding numbers.

MM = Month
DD = Day of month
hh = Hour (24 hr format)
mm= Minute
YYYY = Year

For this example we are setting the time to Wed Jul 25 23:35:51 CDT 2012:

The month is Jul so that translates into 07
The day of the month is the 25th
The hour is 23
The minutes is 35
The year is 2012

So the combined date string would be
$ date 072523352012

Online Documentation:
 

furquan

Well-Known Member
Jul 27, 2002
473
4
168
But my system date is perfectly fine, I dont need to change that.

It is only when I use that function in MySQL it shows wrong date :(
 

furquan

Well-Known Member
Jul 27, 2002
473
4
168
Yes, it is what it should be.

There is no problem with system date, Except this Mysql issue :(
 

CitizenK

Well-Known Member
Jun 5, 2012
64
1
58
On The Road
cPanel Access Level
Root Administrator
That is a very interesting error. I recommend that you open a suport ticket using the link in my signature so we can access your server and investigate your issue further.

Please make sure that you link to this thread in your ticket and post your ticket number here.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
42
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
This is a common issue if you change the system time or date and MySQL has not been restarted. You simply need to restart MySQL to fix it:

Code:
/etc/init.d/mysql restart
If this does not fix it, please then let us know.