How to format RSS pubDate to DateTime?

How to set mysql date from a result set to a php datetime object?

  • i am trying to set the date and time (DateTime stored in mysql database) to a php DateTime object, one way is to override the class some how to make that happen, but is there any easier way than that? e.g. $date = new DateTime(); $date->setDate($mysql_resultset['date_… and then format that date according and display it.

  • Answer:

    $date = date('Y-m-d',strtotime($date_from_mysql)… you can use any date formatting as first parameter, second is date string.

Ayub Zafar at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.