views:

20

answers:

1

I used this code

$new_date = date('Y-m-d H:i:s', timetostr($orig_date));

to convert this input Wed Jun 2 2010 to a datetime output 2010-06-02 00:00:00

When I read it from the database, how do I convert it back to the original format of Wed Jun 2 2010?

A: 

You can use the function strftime() (see php.net manual: strftime() for further information and all parameters) with specified parameters to convert the timestamp back to a human-readable format.

You can use the function this way strftime("%a %b %d %Y") where %a stands for the shortened name of the weekday, %b for the shortened name of the month, %d for the day of the month and %Y for the YYYY representation of the specified year.

Marius Schulz
Thanks a lot, what I was looking for.
duder