Format datetime string in php

Assuming you have a string represents some datetime:

$mydatetime_str = 'Oct 20 18:29:50 2001 GMT';

dTo reformat the above datetime string to mm/dd/yyyy, use this:

$newdatetime_str = strftime("%m/%d/%Y", strtotime($mydatetime));


For more details about strftimehttp://php.net/manual/en/function.strftime.php

Comments