4

According to the following documentation the format of dates returned from the Facebook API can be adjusted via the date_format parameter. In the REST URL below I have implemented the parameter "U" in a facebook event call specifying that I'd like my date returned as a UNIX time stamp.

https://graph.facebook.com/269229076559525?date_format=U?access_token

If you look at the returned JSON the updated_time field is now returned as a unix time stamp but the start_time field is unaffected.

{
  "id": "269229076559525", 
  "owner": {
    "name": "{removed}", 
    "id": "{removed}"
  }, 
  "name": "Windham Flat's Winter Dance Party", 
  "description": "Windham Flat's Winter Dance Party, Featuring:\n\nWindham Flat\nThat's Not Her\nEl Super Ritmo!\n\nSaturday, December 21st, Make-Out Room\n", 
  "start_time": "2013-12-21T19:30:00-0800", 
  "timezone": "America/Los_Angeles", 
  "is_date_only": false, 
  "location": "Make-Out Room", 
  "venue": {
    "latitude": 37.755280780054, 
    "longitude": -122.41943796736, 
    "city": "San Francisco", 
    "state": "CA", 
    "country": "United States", 
    "id": "32498706383", 
    "street": "3225 22nd Street", 
    "zip": "94110"
  }, 
  "privacy": "OPEN", 
  "updated_time": 1386740974
}

Can any one suggest how I might get the API to return my start_time as the specified date_format as well.

Ben Pearce
  • 6,884
  • 18
  • 70
  • 127
  • Why can you not convert the time on your end? – Andy Jones Dec 17 '13 at 01:50
  • I'm using javascript in a Phone Gap App. I've found date formatting to be shockingly troublesome in that context. That being the case it would be great to cut out an additional format conversion. – Ben Pearce Dec 17 '13 at 02:40
  • I'm having this problem, it's been a year since your question. Did you solve it? Edit: works with posts (created_time field), but doesn't work with events. – DariusL Dec 18 '14 at 09:39
  • I have used another way to convert started time in my code, First of all you do remove the "date_format=U" from the Graph api and convert the start_time like as, NSString *aStrDate = @"2016-09-01T16:50:22+0000"; NSDateFormatter *aDateFormatter = [[NSDateFormatter alloc] init]; aDateFormatter.dateFormat = @"yyyy'-'MM'-'dd'T'HH':'mm':'ss+SSSS"; NSDate *aDate = [aDateFormatter dateFromString:aStrDate]; aDateFormatter.dateFormat = @"yyyy-MM-dd HH:mm:ss"; NSLog(@"%@",[aDateFormatter stringFromDate:aDate]); – ssowri1 Sep 02 '16 at 05:35
  • 1
    Hello from 2017! This is still a problem I've encountered. – Salem Apr 02 '17 at 16:31
  • Try this pattern: https://stackoverflow.com/questions/20720417/how-to-parse-time-from-date-string-retrieved-from-facebook – Effi Aug 01 '22 at 11:57

0 Answers0