ohdang888 Posted November 13, 2011 Share Posted November 13, 2011 I'm given something like this: Sun Nov 06 2011 09:30:00 GMT-0500 (EST) And i'm trying to turn that into 2011-11-06 09:30:00 I started by using explode and trying to loop through the day and month to figure it out, but that seems inefficient and overly complicated. Am i missing something? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/251037-get-datetime-from-string/ Share on other sites More sharing options...
gizmola Posted November 13, 2011 Share Posted November 13, 2011 strtotime Quote Link to comment https://forums.phpfreaks.com/topic/251037-get-datetime-from-string/#findComment-1287734 Share on other sites More sharing options...
ohdang888 Posted November 13, 2011 Author Share Posted November 13, 2011 strtotime Thanks! knew it should that simple. BUT from that exact string i'm getting this time: using Sun Nov 06 2011 09:30:00 GMT-0500 (EST) getting 2011-11-06 4:30:00 using <?php echo date('Y-m-d G:i:s', strtotime(url_decode($_GET["start"]))); ?> I changed the timezone to EST, and its still coming up with the same thing. I've tried messing around with it, but not getting it to work. How do i adust for this difference? thanks Quote Link to comment https://forums.phpfreaks.com/topic/251037-get-datetime-from-string/#findComment-1287740 Share on other sites More sharing options...
MasterACE14 Posted November 13, 2011 Share Posted November 13, 2011 date_default_timezone_set() Quote Link to comment https://forums.phpfreaks.com/topic/251037-get-datetime-from-string/#findComment-1287743 Share on other sites More sharing options...
ohdang888 Posted November 13, 2011 Author Share Posted November 13, 2011 date_default_timezone_set() Ya i used date_default_timezone_set("America/New_York"); before anything. And that's what I'm getting. I'm assuming I needed to set it to EST because the time is in EST and i want it to match Quote Link to comment https://forums.phpfreaks.com/topic/251037-get-datetime-from-string/#findComment-1287744 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.