Okay, I've had enough! This should be a simple one, but I haven't found the answer anywhere. I am pulling a date out of mysql db along with other information used by customers to view their account activity. I want to have the dates, time and time used converted from the mysql formats to regular dates (January 1, 2001) and the time used from seconds to hh.mm.ss. Once I have retreived the data I create an array )(mysql_fetch_array) for all the fields necessary to produce the report. I use "while" to print the activity report.

I have used the DATE_FORMAT in the query but it doesn't produce a date in the activity report. I have used "printf" to format the date but that doesn't work either.

What am I missing?

    • [deleted]

    Any chance of a some code to see what you did wrong?

      It's not so much what I did wrong as not knowing what to do. Here is the important part of the code.

      I need to get $date formatted properly as well as $length (now in seconds, so I could just calculate that unless there's a more succinct method).

      $history_info="SELECT starttime, stoptime, length, date FROM logs WHERE personal='$id' ORDER BY date DESC, starttime DESC";
      $result=mysql_query($history_info);

      while ($row = mysql_fetch_array($result, $connection)){
      $show_date=$row["date"];
      $show_starttime=$row["starttime"];
      $show_stoptime=$row["stoptime"];
      $show_length=$row["length"];

      echo ?>

      <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
      <td class="text" width="25%">
      <?=$show_date?>

        • [deleted]

        When using the date_format() function in mysql, be sure to out the 'as' argument in, otherwise you'll have a ball looking for the results. For the time, use sec_to_time()

        SELECT date_format(blabla) as mydate,
        sec_to_time(seconds_col) as mytime
        FROM table
        WHERE bla;

          Done! Thanks a lot Vincent.

            Write a Reply...