PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
MrToast
Forum Newbie
Posts: 3 Joined: Mon Jun 13, 2005 9:17 am
Location: Land of the Golden Gophers
Post
by MrToast » Thu Jun 23, 2005 12:10 am
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
andre_c
Forum Contributor
Posts: 412 Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah
Post
by andre_c » Thu Jun 23, 2005 12:22 am
try removing the @ sign
Code: Select all
$date = str_replace("@", "", "Jun. 21st, 2005 @ 11:53 am");
$unix_date = strtotime( $date );
MrToast
Forum Newbie
Posts: 3 Joined: Mon Jun 13, 2005 9:17 am
Location: Land of the Golden Gophers
Post
by MrToast » Thu Jun 23, 2005 12:35 am
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
andre_c
Forum Contributor
Posts: 412 Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah
Post
by andre_c » Thu Jun 23, 2005 12:39 am
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")));
MrToast
Forum Newbie
Posts: 3 Joined: Mon Jun 13, 2005 9:17 am
Location: Land of the Golden Gophers
Post
by MrToast » Thu Jun 23, 2005 10:45 am
Thanks, that worked!
MrToast