Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想计算一个顾问到海外旅行的津贴。我必须考虑到我可以在国际旅行中获得一天或损失一天。不同的国家有不同的配额。
我如何调整我的代码以知道我会赢一天还是输一天并调整我的计算?
使用当地时区信息输入日期/时间。将两个日期/时间从该时区转换为 UTC,并根据 UTC 计算两者之间的差异。
例如:
左:2008 年 11 月 11 日上午 10 点 CST(芝加哥)== 2008 年 11 月 11 日下午 4 点 UTC (-6)
抵达时间:2008 年 11 月 12 日凌晨 5 点 CET(哥本哈根)== 2008 年 11 月 12 日凌晨 4 点 UTC (+1)
差异 = 12 小时