开发者

what date/time considerations when we create event based site?

开发者 https://www.devze.com 2023-01-10 07:28 出处:网络
I would like to know how to handle date and time if we do any site where we ask users to create evetns like evite.com. my confusion is, if I create an event for Aug 5th and then invite 200 persons fro

I would like to know how to handle date and time if we do any site where we ask users to create evetns like evite.com. my confusion is, if I create an event for Aug 5th and then invite 200 persons from different places(outside the event country), how evite sends the reminder because the time is different in some countries i.e. it will be still 4th in some country but 5th in some countries. Also, when we do any time calcualtion it takes the servers time where the site is hosted, is this the right way and just 开发者_Go百科leave it like that?

please throw some light.

regards


The server time is useless.

For future events, you have to store both the time of the event in the form "yyyy-mm-dd hh:mm:ss" and the timezone of the event (e.g. "Europe/Lisbon"). Do not store the timestamp and the timezone unless it's some kind of astronomical event whose time depends not on the legal time of the country/region where the event happens but on some absolute time point.

Then, you can calculate the time of the event like this (e.g.):

//Let's say the event happens in Lisbon
$d = new DateTime("2010-08-10 17:00:00", new DateTimeZone("Europe/Lisbon"));
echo "The event occurs on ", $d->format("r"), " (local time).";
//let's say the user is in India
$d2 = $d->setTimezone(new DateTimeZone("Asia/Calcutta"));
echo "The event occurs on ", $d->format("r"), " (your time).";

Further reading: Storing Date/Times in Databases


Convert all the time to GMT before storing. That way you have a common date/time for the entire earth.

You also need to have your members specify the time zone they are in, so that you can display the events in the correct time for them.

0

精彩评论

暂无评论...
验证码 换一张
取 消