Handling Facebook Date/Times

December 28th, 2009 @ 5:19 pm

0

Facebook Logo

Today I was playing around with the facebook api and needed to extract the date and time for each event. When you look at the value from the api call, you get something along the lines of:

1262028000

For the date of the event from the facebook event page, is 28th Dec 09 11:20, so what is the result above all about? Well it’s Unix Epoch Time representation of the time, however the wonderful folks of facebook convert the time into pacific time, before then converting it to Unix Epoch time. So in php to extract the date/time in your local time zone do the following:

date_default_timezone_set(‘America/Los_Angeles’);

$startDate = date(‘d m Y H:i’, $eventInfo['start_time']);

and this will give you a time like this:

28 12 2009 11:20

I can’t take any of the credit for this, all of it has to go marc2003 over at forums.overclockers.co.uk.

Anyone looking for more info on handling facebook events api I strongly recommend this site – http://www.phpeveryday.com/articles/Facebook-Programming-API-Events-P852.html

Want to enter some HTML?

Then feel free to use - <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Leave a comment: