问题标签 [nstimezone]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
ios - 格林威治标准时间与夏令时更改的本地时间转换
从服务器我收到 GMT 时间结构(用户定义的结构),使用我想将其转换为本地时间,我通过用接收到的结构填充 NSDatecomponent 来完成它,然后我使用日期格式化程序从中获取日期它,除了一种情况外,一切正常。如果 GMT 时间在 11 月 3 日之后(美国夏令时更改),则格式化程序会产生 1 小时的时差。
例如:如果预期时间是 11 月 3 日下午 4 点,则在从 GMT 转换为本地时间后,将给出 11 月 3 日下午 3 点。
任何想法如何避免它。
编辑:
sel_date_time 字符串比它应该的时间少一小时..
日志 :
strt_date_loc = 2013-11-30 06:56:00 +0000
sel_date_time = 2013 年 11 月 29 日晚上 10:56(但应该是晚上 11:56)
时区:帕洛阿尔托(美国)
本地到 GMT 转换:
谢谢。
ios - UILocalNotification 延迟 1 小时
我个人没有遇到过这个问题,但是对于我的一些用户来说,设置一次的通知实际上是在一小时后触发的。
这是我用来生成通知的代码:
相当标准。遇到问题的用户是英国时间,该时间有夏令时。我想知道这是否是某种iOS错误?
ios - 将 iOS localTimeZone 转换为 knownTimeZone
使用NSTimeZone
的列表与检索到的knownTimeZoneNames
不匹配。如何将时区从 转换为时区。更具体地说,时区返回值必须与此时区列表中的时区匹配。timezone
localTimeZone
localTimeZone
knownTimeZoneNames
.name
ios - 从 UIDatePicker 中选择的日期与保存的日期不同
这就是我设置 datePicker 的方式
这就是我保存所选日期的方式
如果我从日期选择器中选择 Nov 18 2013,则 NSLog 显示
但是,在我的代码中的某处,我需要获取今天的日期和我在日期选择器中选择的日期之间的天数差异。
今天是 11 月 10 日。我保存的日期是 11 月 18 日。但是天数差是 7,而不是 8。
objective-c - NSDate 和 NSDate stringFromDate 不一致
我正在尝试将 mysql 日期时间字段转换为另一个时区。当我打印日期对象时,转换似乎是正确的,但是当我将日期打印为字符串时,时间不正确。源代码和输出如下。
资源:
编辑 - 以秒和字符串打印原始间隔,添加时区
输出:
间隔毫秒:1384193573000
original date: 01:12 2013-11-11 //当前时区日期: America/Phoenix
日期:2013-11-11 08:12:00 +0000 //新时区日期:美国/纽约
日期字符串:2013-11-11 01:12
ios - 无论用户身在何处,如何找出用户的晚上 8:00?
我正在实施UILocalNotification
以在晚上 8:00 提醒首次使用该应用程序的用户再次使用该应用程序。用户可以将其完全关闭或设置不同的时间。
我选择晚上 8:00 作为下班后的时间,这样它就不会那么打扰或打扰了。
我不确定如何处理时区。
如果用户在纽约。[NSDate date]
仅返回 GMT 日期时间(自参考日期以来的某个时刻)。那么我如何确定他的晚上 8:00 呢?
我可以这样做吗?
objective-c - Date calculations without daylight savings time
I'm trying to perform date calculations for a scheduling app but am running into issues with daylight savings time. I'm trying to determine the number of days between two dates with:
#xA;where self.viewBeginDate
and item.ES
are both NSDate objects and self.calendar
is a gregorian calendar.
- When calculating between Nov 1, 2013 and Nov 1, 2013, it provides 0.
- When calculating between Nov 1, 2013 and Nov 2, 2013, it provides 1.
- When calculating between Nov 1, 2013 and Nov 3, 2013, it provides 2.
- When calculating between Nov 1, 2013 and Nov 4, 2013, it provides 2 again!
Here is my output:
#xA;I'd like to be able to determine the number of days between 2 NSDate
objects without impact by Daylight Savings Time, as my app doesn't care what local or timezone the user is in. I just want it to tell me that there are 3 days between Nov 1, 2013 and Nov 4, 2013. Any thoughts?
My NSDate
objects are created from strings in the format of: 2013-11-01 00:00:00 +0000. Each date has the time set to 00:00:00 with the GMT offset of +0000.
I've thought of two possible options:
- Use
isDaylightSavingTime
to check each date and create a new (modified) date offset by 1 hour if it the date is Daylight Savings Time. I'm worried about the added calculation time as my app calculates the date between a given begin date and an array of other dates. This array may have up to 2,000 dates in it. I'm not sure if that's a legit concern or not... - create a custom timezone that is not affected by DST. Is this even possible?
core-data - 将 NSTimeZone 存储在核心数据中
我试图保存NSTimeZone
为可转换类型,但它似乎不起作用,因为它符合NSSecureCoding
.
有没有其他选择?
ios - iOS 开发 - 将城市与 NSTimezone Offline 关联
希望你们一切都好。
所以我正在开发一个时区iOS应用程序。该应用程序要求我们有一个人口众多的城市列表,并且当用户选择一个时,它会确定构造 NSTimeZone 对象(然后我们将其用于 NSDate 转换)所需的 Olson 时区 ID。
我已经能够获得城市列表及其对应的 lat 和 lng,我计划将其输入 Geoname 的 Timezone 服务端点,以确定每个城市的上述 Olson 时区 ID。
问题是我需要提出的请求数量巨大,我想知道是否没有更简单的解决方案来解决我的问题。任何建议/想法将不胜感激。
感谢大家!
ios - UILocalNotification - 每个时区早上 6:00 触发
我无法理解时区,似乎无法解决它。
用户应输入警报响起的时间。因此,他们在澳大利亚悉尼时区选择周日早上 6:00(使用 pickerView)。
然后,当他们的设备将时区更改为美国洛杉矶时,警报仍应在洛杉矶时间早上 6:00 响起(现在是悉尼时间凌晨 1:00 或其他时间)。
设置通知:
读取通知以显示在 TableView 中:
使用该代码,我将悉尼的时间设置为上午 6:00,但在洛杉矶查看时,时间现在是下午 1:00。
在设置 UILocalNotification 时我应该将时区设置为什么,以及在阅读通知时我应该将时区设置为什么,以便在悉尼和洛杉矶查看时,时间都是当地时间上午 6:00。
谢谢