I'm trying to format a date taken from a MySQL DATETIME field.
echo strftime('%d/%m/%y at %i:%M:%S', '2001-04-27 18:11:27');
is outputting
01/01/1970 at 12:33:21
which is totally wrong!
Anyone have any ideas?!
Thanks,
I'm trying to format a date taken from a MySQL DATETIME field.
echo strftime('%d/%m/%y at %i:%M:%S', '2001-04-27 18:11:27');
is outputting
01/01/1970 at 12:33:21
which is totally wrong!
Anyone have any ideas?!
Thanks,
Try this:
echo strftime('%d/%m/%y at %H:%M:%S', strtotime('2001-04-27 18:11:27'));
It converts your date string into a UNIX timestamp, and then formats it. I switched to 'H' instead of 'i'. strftime doesn't allow a lower case 'i', and the upper case 'i' returns a 12hr format instead of an 24hr format. You can use %p if you want to show am and pm.
I thought thair might be something like that to convert it to a unix timestamp, but I couldn't find anything in the manual.
Thanks!
Danny