Convert date and time to source format

I used this code

$new_date = date('Ymd H:i:s', timetostr($orig_date)); 

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

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

-1
source share
1 answer

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

You can use the function in this way strftime("%a %b %d %Y") , where% a stands for the abbreviated name of the day of the week,% b for the abbreviated name of the month,% d for the day of the month and% Y to represent YYYY of the specified year.

+1
source

Source: https://habr.com/ru/post/904452/


All Articles