Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top