Page 1 of 1
Changing date format
Posted: Thu Jun 23, 2005 12:10 am
by MrToast
Hi everyone,
I've got a date string I'm pulling off of a website that's in the form:
What would be the best way to go about converting this to a PHP-usable date? I've checked out the "strtotime()" function, but that returns -1 (ie it couldn't convert the string).
Any ideas?
Thanks!
MrToast
Posted: Thu Jun 23, 2005 12:22 am
by andre_c
try removing the @ sign
Code: Select all
$date = str_replace("@", "", "Jun. 21st, 2005 @ 11:53 am");
$unix_date = strtotime( $date );
Posted: Thu Jun 23, 2005 12:35 am
by MrToast
Well, this is a step in the right direction!
After taking out the "@" and trying strtotime() again, I now end up with
instead of "-1".
So... progress... kinda....
MrToast
Posted: Thu Jun 23, 2005 12:39 am
by andre_c
just tested it, it worked for me
show the rest of the code
for a mysql date field it should be something like this
Code: Select all
$date = date("Y-m-d H:i:s", strtotime( str_replace("@", "", "Jun. 21st, 2005 @ 11:53 am")));
Posted: Thu Jun 23, 2005 10:45 am
by MrToast
Thanks, that worked!
MrToast