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 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题