doudichu1358 2015-01-26 17:33
浏览 16
已采纳

管理当地时间和时区

I develop an Android app where the user retrieves from the database server events which are organized. Each event has a date and an hour.

My problem is:

  • My server is in Paris and it's 6 pm.
  • The user is in New York and it's noon.

The user logs in and retrieves the events planned in New York today. The server gets in database events where the date exceeds the current date. Problem, the server is later in the day than the user, so the user won't see events planned the afternoon.

How can I fix this?

I can get the timezone of the user and of the events but how can I manage? Does the server puts all the dates of the events in the timezone of Paris in database or I let in database the events in local times.

  • Ex: An event planned at noon in New York, should I store it with the local timezone (noon) or with the server timezone (6 pm)? And after how works the comparison?

Thank you for your answers.

  • 写回答

1条回答 默认 最新

  • duanjianxiu9400 2015-01-26 17:38
    关注

    I would recommend converting your server to store/load data in UTC and also for your client to use UTC time in the background. This will help ensure that they are both using the same time zone for comparison.

    This is usually the recommended approach since UTC is the standard and will never be affected by daylight savings time.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测