Suppose a user of your website enters a date range.
(假设您网站的用户输入了日期范围。)
2009-1-1 to 2009-1-3
You need to send this date to a server for some processing, but the server expects all dates and times to be in UTC.
(您需要将此日期发送到服务器进行某些处理,但是服务器希望所有日期和时间都采用UTC。)
Now suppose the user is in Alaska or Hawaii or Fiji.
(现在,假设用户位于阿拉斯加,夏威夷或斐济。)
Since they are in a timezone quite different from UTC, the date range needs to be converted to something like this: (由于它们所处的时区与UTC截然不同,因此需要将日期范围转换为以下形式:)
2009-1-1T8:00:00 to 2009-1-4T7:59:59
Using the JavaScript Date object, how would you convert the first "localized" date range into something the server will understand?
(使用JavaScript Date对象,您如何将第一个“本地化”日期范围转换为服务器可以理解的范围?)
ask by dthrasher translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…