timezone

How can I get DateTime data from SQL Server ignoring time zone issues?

耗尽温柔 提交于 2021-02-07 03:30:40
问题 My situation is that we store data in a SQL Server database, supporting 2005 on up. When a DateTime value is stored, it is in the local time of the client. I need to be able to get that date back on any other client, anywhere, without respect to whatever time zone that other client might be in. So for instance, when a user in New York enters a DateTime value of "2012-12-20 00:00", I want the user in California to see that very same DateTime value. These DateTime values should not respect the

Postgres Timestamp

一世执手 提交于 2021-02-06 21:40:12
问题 We are having a debate about the best way to store a timestamp in postgres. Currently all time stamps are stored as +00 and we have a timezone associated with each client. We look up the timezone and convert the time that something happened which increases complexity as we need to do more joins and a more complex query. Another method is connecting to Postgres and setting the timezone of the connection and it changes all the times to be that timezone. My problem with this is that in ANZ there

Postgres Timestamp

此生再无相见时 提交于 2021-02-06 21:38:31
问题 We are having a debate about the best way to store a timestamp in postgres. Currently all time stamps are stored as +00 and we have a timezone associated with each client. We look up the timezone and convert the time that something happened which increases complexity as we need to do more joins and a more complex query. Another method is connecting to Postgres and setting the timezone of the connection and it changes all the times to be that timezone. My problem with this is that in ANZ there

How to store TimeZoneInfo objects in a database?

▼魔方 西西 提交于 2021-02-06 15:21:53
问题 Somewhat misleading title, I know. Never actually wanted to store TimeZoneInfo object themselves: rather, I want to store some culture-neutral identifier, which can then be later used to reconstruct an instance of TimeZoneInfo . Currently, I'm storing the value of TimeZoneInfo.Id property and it seems to be OK both on English and Russian versions of Windows, but I just wanted to make sure I do the right thing. 回答1: Yes, Id is a non-localized identifier, so that's an appropriate thing to store

How to store TimeZoneInfo objects in a database?

强颜欢笑 提交于 2021-02-06 15:18:32
问题 Somewhat misleading title, I know. Never actually wanted to store TimeZoneInfo object themselves: rather, I want to store some culture-neutral identifier, which can then be later used to reconstruct an instance of TimeZoneInfo . Currently, I'm storing the value of TimeZoneInfo.Id property and it seems to be OK both on English and Russian versions of Windows, but I just wanted to make sure I do the right thing. 回答1: Yes, Id is a non-localized identifier, so that's an appropriate thing to store

How to write the right time to DB according my timezone?

ε祈祈猫儿з 提交于 2021-02-05 09:44:58
问题 When I save dates in my database Django shows message about succesfull adding with the right time but in fact in the databese time is different models.py: from datetime import datetime from django.db import models class Teg1(models.Model): created_at = models.DateTimeField(default=datetime.now, null=True, blank=True, editable=False) num = models.FloatField(default=0.0, null=True, blank=True) def __str__(self): return str(self.num) + " || " + str(self.created_at) settings.py TIME_ZONE = 'Asia

add time units to a date without timezone

佐手、 提交于 2021-02-05 08:36:06
问题 I write these in Linux bash date -d "2018-08-21 02:00:00" +'%y-%m-%d %T' and it prints 2018-08-21 02:00:00 But when I write these date -d "2018-08-21 02:00:00 +1 hour" +'%y-%m-%d %T' it prints 2018-08-21 07:30:00 instead of 2018-08-21 03:00:00 It adds my timezone to the date . How can I ignore timezone when I'm adding time units? 回答1: What is happening is that the +1 is interpreted as the timezone UTC+1h . So it will convert your input date from UTC+1 to your local time-zone and then still

How to use a specific GMT for a function which will be recognised by other time zones

主宰稳场 提交于 2021-02-05 08:33:36
问题 I imagine there's a simple way to do this, I just haven't figured it out yet. I want to display a button only between 9am to 12pm AEST (GMT+10). So for a user in AWST (GMT+8), they will not be able to see the button when it is 11am for them. I have the specific time I want to use let date = Date() let dateFormatterTime = DateFormatter() dateFormatterTime.dateFormat = "HH:mm:ss" dateFormatterTime.timeZone = TimeZone(secondsFromGMT: 36000) let sydneyTime = dateFormatterTime.string(from: date)

How to use a specific GMT for a function which will be recognised by other time zones

。_饼干妹妹 提交于 2021-02-05 08:33:28
问题 I imagine there's a simple way to do this, I just haven't figured it out yet. I want to display a button only between 9am to 12pm AEST (GMT+10). So for a user in AWST (GMT+8), they will not be able to see the button when it is 11am for them. I have the specific time I want to use let date = Date() let dateFormatterTime = DateFormatter() dateFormatterTime.dateFormat = "HH:mm:ss" dateFormatterTime.timeZone = TimeZone(secondsFromGMT: 36000) let sydneyTime = dateFormatterTime.string(from: date)

How to pick a timezone based on UTC offset?

你。 提交于 2021-02-05 06:21:33
问题 i've got a silly problem. I'm parsing Facebook user data, and I get the timezone as a number: timezone: The user's timezone offset from UTC For me ( 'America/Argentina/Buenos_Aires' ) it's -3. Now, how can I convert that number to a pytz.timezone ? Thank you! 回答1: There's not a 1:1 correspondence, so there's no way to do it without making some assumptions that are bound to be invalid. You can create your own tzinfo class that encodes the offset directly without trying to tie it back to a zone