The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MySQL Showing wrong date

Discussion in 'Database Discussions' started by furquan, Jul 25, 2012.

  1. furquan

    furquan Well-Known Member

    Joined:
    Jul 27, 2002
    Messages:
    425
    Likes Received:
    0
    Trophy Points:
    16
    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,
     
  2. CitizenK

    CitizenK Well-Known Member

    Joined:
    Jun 5, 2012
    Messages:
    64
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    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,
     
  3. furquan

    furquan Well-Known Member

    Joined:
    Jul 27, 2002
    Messages:
    425
    Likes Received:
    0
    Trophy Points:
    16
    This is what I get :-

    root@ind [~]# date MMDDhhmmYYYY
    date: invalid date `MMDDhhmmYYYY'
     
  4. CitizenK

    CitizenK Well-Known Member

    Joined:
    Jun 5, 2012
    Messages:
    64
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    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 25[sup]th[/sup]
    The hour is 23
    The minutes is 35
    The year is 2012

    So the combined date string would be
    $ date 072523352012

    Online Documentation:
     
  5. furquan

    furquan Well-Known Member

    Joined:
    Jul 27, 2002
    Messages:
    425
    Likes Received:
    0
    Trophy Points:
    16
    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 :(
     
  6. CitizenK

    CitizenK Well-Known Member

    Joined:
    Jun 5, 2012
    Messages:
    64
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    On The Road
    cPanel Access Level:
    Root Administrator
    Can you confirm that you have the correct timezone set in WHM >> Server Configuration >> Server Time

    Thanks,
     
  7. furquan

    furquan Well-Known Member

    Joined:
    Jul 27, 2002
    Messages:
    425
    Likes Received:
    0
    Trophy Points:
    16
    Yes, it is what it should be.

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

    CitizenK Well-Known Member

    Joined:
    Jun 5, 2012
    Messages:
    64
    Likes Received:
    1
    Trophy Points:
    8
    Location:
    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.
     
  9. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    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.
     
Loading...

Share This Page