January 5th, 2009 TIME output

  • Not sure if this is a mysql question or not.

    I have a DB table with a TIME field like 12:30:00, I would like the output on the web page to have one hour subtracted from it. So it would read 11:30:00.

    Can that be done?

    Thanks
    Chad


  • That is pretty bad if you get a date like 0:00:00 because you will get a -1, and it is really annoying to check that by yourself.

    You can do it from the select statement right away like

    $data = mysql_query("SELECT date_sub(field, INTERVAL 1 hour) FROM table");


  • Assuming the date queried is stored in a variable, you can go about it as follows:

    $newdate = explode(":", $olddate);
    $newdate[0] = $newdate[0] - 1;
    $olddate = "$newdate[0]:$newdate[1]:$newdate[2]";


  • Thank You!:D It did exactly what I needed it to do!







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about TIME output , Please add it free.