gunter Posted March 19, 2014 Share Posted March 19, 2014 Hi, I have a question about best practices for my case: I want import events from a google calendar - and I want make calculations with the begin and end time of the event (add a half our.. substract a half our)... which format shall I use for storing the date time? sorry for my asking, I am a little bit lost and the php date is making me a little bit crazy! The google calender uses RFC3339...begin: 2014-03-27T17:00:00.000+01:00end: 2014-03-27T20:00:00.000+01:00 Link to comment Share on other sites More sharing options...
adrian Posted March 20, 2014 Share Posted March 20, 2014 I would suggest that you should store it in this format : 2014-03-19 17:20:10 which is the standard datetime format in mysql. PW does all its conversions from this and you can easily do the same with PHP's date function. Keep in mind that you need to convert from this to unixtime using strtotime before using php date. So, you can convert from RFC3339 to store in PW like this: $pw_date_format = date('Y-m-d H:i:s', strtotime("2014-03-27T17:00:00.000+01:00")); and then take that and add 30 minutes and convert to RFC3339 $RFC3339 = date("Y-m-d\TH:i:sP", strtotime('+30 minutes', $pw_date_format)); You could also make use of PHP's DateTime class: http://www.php.net/manual/en/class.datetime.php Link to comment Share on other sites More sharing options...
gunter Posted March 20, 2014 Author Share Posted March 20, 2014 Thanks, Adrian! I will try this! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now