Hi all,

I am trying to convert the date format in the text file into a SQL Datetime format so that i can insert it into my table. Currently, the format in the txt file for the date is something like: Fri Mar 26 06:57:19 2010

Is there a better way then using mktime() as it require that i explode the text above to add in as parameters. Is it not possible to use a date formatter to accept my date input as above and convert it into the desired sql date time format as specified?

I just picked up PHP yesterday and so i am very new to this. Any help would be appreciated. Thanks

    bradgrafelman;10979274 wrote:

    Use MySQL's STR_TO_DATE() function to format the date inside the SQL query itself.

    But i would like to use the datetime from the text file to insert into the SQL query. I have problem trying to add datetime to a row in MySQL.

      I think i just solved my own question. All i did was:

      $date="Sat Nov 20 00:53:37 2010";
      $sqlDateTime = date('Y-m-d H:i:s', strtotime($date));
      

      Thanks

        Write a Reply...