BandonRandon Posted July 30, 2008 Share Posted July 30, 2008 Hello, I don't know if this is the place to post this and if not i'm sorry. I am creating a podcast admin which will let users import data into a database then create xml based off of that. I currently have a list of drop down that allow the user to select the weekday, day, time etc then when that is done it outputs it into a database cell in the complete rfc 2822 format (Wed, 6 Jul 2005 13:00:00 PDT) Everything is working fine except i want the user to be able to modify the podcast later which means i need to be able to pull the data back out and into the selection boxes. I'm not sure if i should explode the date or what. The other option would be have multiple tables for date but that seams messy and unnecessary. Any help on this would be great. Thanks! Brandon Quote Link to comment https://forums.phpfreaks.com/topic/117420-solved-explode-rfc-2822-date/ Share on other sites More sharing options...
obsidian Posted July 30, 2008 Share Posted July 30, 2008 Since RFC is a readable format, you can use strtotime() and get whatever you need from it using the date function: <?php $ts = strtotime('Wed, 6 Jul 2005 13:00:00 PDT'); echo date('Y-m-d g:i:s a', $ts); ?> Quote Link to comment https://forums.phpfreaks.com/topic/117420-solved-explode-rfc-2822-date/#findComment-603968 Share on other sites More sharing options...
BandonRandon Posted July 30, 2008 Author Share Posted July 30, 2008 obsidian, First off I owe you an award for fastest response time ever! Second that works wonders! Thank you so much! Brandon Quote Link to comment https://forums.phpfreaks.com/topic/117420-solved-explode-rfc-2822-date/#findComment-603974 Share on other sites More sharing options...
BandonRandon Posted August 1, 2008 Author Share Posted August 1, 2008 Hi, I've found one small problem with pulling the time this way. It will pull the time fine but will try to put it in either the severs current time zone or whatever timezone i specify. Is there a way to have it pull the time but keep it in the timezone it was originally set in? Thanks, Brandon Quote Link to comment https://forums.phpfreaks.com/topic/117420-solved-explode-rfc-2822-date/#findComment-605295 Share on other sites More sharing options...
obsidian Posted August 1, 2008 Share Posted August 1, 2008 I've found one small problem with pulling the time this way. It will pull the time fine but will try to put it in either the severs current time zone or whatever timezone i specify. Is there a way to have it pull the time but keep it in the timezone it was originally set in? Actually, if you're seeing the same thing I am, the date/time that is interpreted from the strtotime() call is accurate, but the date() function does output in the server time, but that time is relative to the date and time entered. So, for instance, my server is in EST: the time input was 1:00pm, and the time output by my server is 4:00pm on the date provided. So, the reading of your time is accurate, but you would need to be sure to output it in the timezone appropriate to the user (in this case, yourself). For that solution, if you are running PHP5.1+, you can check out date_default_timezone_set(). Quote Link to comment https://forums.phpfreaks.com/topic/117420-solved-explode-rfc-2822-date/#findComment-605489 Share on other sites More sharing options...
BandonRandon Posted August 4, 2008 Author Share Posted August 4, 2008 Obsidian, thanks again for your help. I understand that this is not an issue with the time being incorrect. However for my application I'm allowing the user to choose what timezone they want the data to be stored in. This works fine until i go to pull the data back out using strtotime(). I apologize if date_default_timezone_set gave the answer to this I'm still fairly new to php and after reviewing the manual i couldn't see how this function could help other than set the timezone (currently being done with putenv(). Thanks, Brandon Quote Link to comment https://forums.phpfreaks.com/topic/117420-solved-explode-rfc-2822-date/#findComment-607245 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.