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!
The easiest way to explain it is with code samples. What programming
language are you working in?
Nathan
I'm working in PHP
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
Thanks again, Nathan
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);
> > >>> -------------------------------------------------------------------------------------
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);