Skip to content
Advertisement

Date conversion in PHP

I have date in the following format –

JavaScript

I want convert this date using php in the following format –

JavaScript

I tried following ways so far but id didn’t work –

JavaScript

There are many questions already available for date conversion on stack overflow itself but none of them answer my question as my date to convert is in different format so, please help me if anyone can. Thanks in advance.

Advertisement

Answer

You may have over-thought it.

Since you are ignoring any timezone differences, just truncate the characters at the end of string that are unnecessary then have strtotime() parse what is left.

Code: (Demo)

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement