event time in /2/open_events

140 views
Skip to first unread message

Michael Reichner

unread,
Dec 1, 2011, 11:01:57 PM12/1/11
to Meetup API
Hello -

I'm having a little trouble understanding how the time field in /2/
open_events responses corresponds to the event time displayed on event
pages. Here are five examples from a pull earlier today.

id time utc_offset Displayed time
-------------------------------------------------------------------------------------
qqfjqyppbgc 16:00 -28800 16:00
41512512 07:30 +7200 17:30
39423092 18:30 -28800 18:30
39365812 10:30 0 18:30
qzrpgcyqdbmb 00:00 +36000 18:00

Can somebody please explain this, and how to calculate displayed time
from time/utc_offset?

Thanks!

Nathan Hamblen

unread,
Dec 2, 2011, 11:21:30 AM12/2/11
to meetu...@googlegroups.com
Hi Michael,

The easiest way to explain it is with code samples. What programming
language are you working in?

Nathan

Michael Reichner

unread,
Dec 2, 2011, 12:25:43 PM12/2/11
to Meetup API
Thanks, Nathan.

I'm working in PHP

Nathan Hamblen

unread,
Dec 2, 2011, 5:24:00 PM12/2/11
to meetu...@googlegroups.com
We've heard about some problems where the user's php environment could
not work with 64 bit integers, causing it to overflow when converting
from json. So that's the first thing to look out for, whether you have
the full long int.

When you have that, you can divide it by 1000 to get seconds, then pass
it to date($format, $timestamp) which gives you the actual time of the
event, adjusted to your local time zone. If you look at your watch at
that time, the event is starting wherever it is.

But if you're displaying dates and times to a user that you assume will
be in the timezone of the event (as the Meetup site itself does), you
want to adjust the time with the offset. Add the offset to the time
event time before doing anything else to it.

At that point the date will print correctly if your local time is utc.
Generally, it isn't, so you need to do something like this:
http://www.php.net/manual/en/function.date.php#93154

(If date_default_timezone_set() is a global change then that code has
race conditions; there are probably better ways.)

Sorry I don't know php well enough to provide a real code example, but I
hope this gets you off in the right direction.

Nathan

Michael Reichner

unread,
Dec 2, 2011, 9:33:52 PM12/2/11
to Meetup API
Setting my timezone to UTC did the trick.

Thanks again, Nathan

Message has been deleted
Message has been deleted

Boloramji

unread,
Dec 5, 2011, 7:43:40 PM12/5/11
to Meetup API
being a newbee to this java script world, it took me a while to
understand this time millseconds!
if you had added one line explanation what about this long number
represent in your API page that would be great.
"Time in milliseconds elapsed from midnight of January 1, 1970
expressed in UTC time zone"
if you want to convert this time to local time add the utc_offset in
milliseconds.

For example, if you are using C# assuming jo is your json object for
the event, tMeetDate is the meetup time in local time zone. This is
how you will convert
long lTime = jo["time"];
long lOffsetTime = jo["utc_offset"];
lTime /= 1000;
lOffsetTime /= 1000;
DateTime tMeetDate = new DateTime(1970,1,1);
tMeetDate = tMeetDate.AddSeconds(lTime);
TimeSpan tsOffset = new TimeSpan(0, 0, (int)lOffsetTime);
tMeetDate = tMeetDate.AddSeconds(lOffsetTime);

> > >>> ---------------------------------------------------------------------------­----------

Dominique

unread,
Nov 16, 2012, 8:31:50 PM11/16/12
to meetu...@googlegroups.com
If you are having problems dealing with the time due to the large size you can leave it as a string, strip off the last three characters to convert to seconds, then use it as an integer and you should be good to go. Using it as an integer before removing the milliseconds may cause problems in some environments.


Dominique

Doug Tangren

unread,
Nov 16, 2012, 10:28:26 PM11/16/12
to meetu...@googlegroups.com

Doug Tangren
Meetup
API Team



On Mon, Dec 5, 2011 at 7:43 PM, Boloramji <r...@demandpoint.com> wrote:
being a newbee to this java script world, it took me a while to
understand this time millseconds!
if you had added one line explanation what about  this  long number
represent in your API page that would be great.
 "Time  in milliseconds elapsed from midnight of January 1, 1970
expressed in UTC time zone"
if you want to convert this time to local time add the utc_offset in
milliseconds.

For example, if you are using C# assuming jo is your json object for
the event, tMeetDate is the meetup time in local time zone. This is
how you will convert
      long lTime = jo["time"];
      long lOffsetTime = jo["utc_offset"];
      lTime /= 1000;
      lOffsetTime /= 1000;
      DateTime tMeetDate = new DateTime(1970,1,1);
      tMeetDate = tMeetDate.AddSeconds(lTime);
      TimeSpan tsOffset = new TimeSpan(0, 0, (int)lOffsetTime);
      tMeetDate = tMeetDate.AddSeconds(lOffsetTime);


Most if not all dates returned by the api are represented in this format. We usually list time with a description like "UTC creation time of the event, in milliseconds since the epoch" The issue of dealing with a 64 bit integer in platforms that only support 32 bit numbers comes up often enough that we should have a special note in the docs. I'll look into adding this.
 
Reply all
Reply to author
Forward
0 new messages