[thelist] [PHP] reformat date...
Vijay Immanuel
codelad at gmail.com
Fri Jan 26 00:01:51 CST 2007
On 1/25/07, Tris <beertastic at gmail.com> wrote:
> However, before I go home.. I have to convert:
>
> (string)3/MAY/07 --> (date for MySQL)2007-05-03
A slightly shorter solution:
$date_array = strptime('3/MAY/07', '%d/%B/%y');
/* outputs mysql-acceptable '2007-6-3 00:00:00' */
echo ($date_array['tm_year'] + 1900) . '-' . ($date_array['tm_mon'] +
1) . '-' . $date_array['tm_mday'] . ' 00:00:00';
--
Vijay Immanuel
More information about the thelist
mailing list