使用 Flex3 根据区域进行日期和时间转换
我正在以(mm/dd/yyyy hh:mm)这种格式从印度向澳大利亚发送日期和时间(我正在预订未来的日期和时间),对于澳大利亚的用户,它应该根据他的当地时间向他显示。澳大利亚比印度晚 5 小时 30 分钟。如何使用flex3来做到这一点?
i am sending the date and time in ( mm/dd/yyyy hh:mm) this format from india to australia( i am booking a date and time for future), for the user in australia it should show him according to his local time. As australia is 5 hrs and 30 mins past to india. how to do it using flex3.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Flex 没有内置时区计算支持(您可以获取本地时钟的偏移量并在 UTC 时间和本地时间之间进行转换,基本上就是这样),您最好的选择是通过服务器进行转换-call(Joda 处理时区计算,包括 DST 偏移量)。
Flex has no timezone calculation support built-in (you can get your local clock's offset and convert between UTC time and local time and that's basically it), your best bet would be to do the conversion via a server-call (with Joda handling the timezone calculations, which includes DST offsets).
首先,使用 Date 类。其次,在发送日期时使用 UTC 值(请参阅 getUTC 系列方法)。因此,当您收到日期时,您会知道它是 UTC 格式,因此您可以使用这些 UTC 值设置 Date 实例(请参阅 setUTC 方法系列)。该类将自动为您进行时区计算,当您将其呈现给用户时,它将处于他们的时区。
First, use the Date class. Second, use UTC values when sending dates (see getUTC family of methods). So when you receive a date, you'll know it is in UTC so you can set up a Date instance with those UTC values (see setUTC family of methods). The class will automatically do the timezone calculations for you and when you present it to the user it will be in their timezone.