用于FQL的datediff函数,还是以其他方式轻松获取事件持续时间?

时间:2014-03-08 20:15:02

标签: facebook-fql

我想从这个单一的Facebook FQL查询中返回事件持续时间。是否有类似我可以使用的SQL datediff函数?

SELECT eid, name, start_time, end_time FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid = me() ) ORDER BY start_time ASC

1 个答案:

答案 0 :(得分:0)

最好的方法就是按照CBroe提到的那样发布流程。

这是在FQL中执行此操作的不完整方法

SELECT start_time, end_time, strtotime(lower(end_time)) - strtotime(lower(start_time)) FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid = me() ) AND strlen(end_time) > 0

并提供样本回复

{
  "data": [
    {
      "start_time": "2015-03-14T21:00:00-0400", 
      "end_time": "2015-03-15T03:00:00-0400", 
      "anon": 21600
    }, 
    {
      "start_time": "2015-02-16T21:00:00-0400", 
      "end_time": "2015-02-17T02:00:00-0400", 
      "anon": 18000
    }, 
    {
      "start_time": "2015-01-30T22:00:00-0400", 
      "end_time": "2015-01-31T08:00:00-0400", 
      "anon": 36000
    }, 
    {
      "start_time": "2015-01-24T18:00:00-0400", 
      "end_time": "2015-01-25T00:00:00-0400", 
      "anon": 21600
    }, 
    {
      "start_time": "2015-01-09T22:00:00-0400", 
      "end_time": "2015-01-10T04:00:00-0400", 
      "anon": 21600
    }, 
    {
      "start_time": "2015-01-02T22:00:00-0400", 
      "end_time": "2015-01-03T04:00:00-0400", 
      "anon": 21600
    }
  ]
}

anon字段以秒为单位返回

  • 21600 = 6小时
  • 18000 = 5小时
  • 36000 = 10小时

正确匹配上述开始和结束时间的差异。