utc

Pytz convert time to UTC without DST

假装没事ソ 提交于 2019-12-11 16:48:59
问题 I've done a quite a bit of research before posting this, but I can't seem to get the conversion right. I have some data which has timestamps, and some have DST applied, and others don't. I thought the correct way to specify that it's without DST is using the is_dst parameter for pytz. All 3 options give the same offset from UTC, which is incorrect. The offset should be +1000. What's the best way to do this conversion, and why does the is_dst parameter not make any difference? pytz_eastern

Handling time-zone between client and server for date-only DateTime

别来无恙 提交于 2019-12-11 14:49:28
问题 I have a custom validation attribute in my ASP.NET Web API application that checks if the date is in the future or not (dates in the future are not allowed). Here's the code: protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (value != null) { var date = (DateTime)value; if (date != null) { if(date.Date > DateTime.UtcNow.Date) { return new ValidationResult(FormatErrorMessage(validationContext.DisplayName), new[] { validationContext.MemberName }

Java - Convert From A Timezone Different From Local To UTC

[亡魂溺海] 提交于 2019-12-11 11:55:30
问题 So from all the posts I read about this issue (for example, Convert timestamp to UTC timezone). I learn that a way to do this conversion is : SimpleDateFormat dfmaputo = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a"); dfmaputo.setTimeZone(TimeZone.getTimeZone("UTC")); long unixtime = dfmaputo.parse(data.get(1)).getTime(); unixtime = unixtime / 1000; output: original date (Maputo Timezone) -- 11/5/2015 1:39:45 PM unix timestamp in UTC --- 1446687585 data.get(1) is the string with the maputo

Timezone awareness differences between System TZ and DB TZ?

北城以北 提交于 2019-12-11 08:01:59
问题 I am currently migrating a database from a local MySQL host to Aurora in RDS. Checking the time zone settings on both systems using: SELECT @@system_time_zone, @@global.time_zone, @@session.time_zone, NOW(), UTC_TIMESTAMP(); Local Mysql +--------------------+--------------------+---------------------+---------------------+---------------------+ | @@system_time_zone | @@global.time_zone | @@session.time_zone | NOW() | UTC_TIMESTAMP() | +--------------------+--------------------+---------------

How to convert UTC to local time

﹥>﹥吖頭↗ 提交于 2019-12-11 06:34:00
问题 I have to develop an application for ePrescribe and need to convert an UTC Time value (for example '2010-01-01T16:09:04.5Z') to local time. Delphi 2010, any suggestions? 回答1: You have to parse the string manually first. Extract the individual values from it, then you can put them into a Win32 SYSTEMTIME record and call SystemTimeToTzSpecificLocalTime() to convert it from UTC to local. You can then use the converted SYSTEMTIME however you need, such as converting it to a TDateTime using

How does javascript know the time zone of a date in milliseconds?

北慕城南 提交于 2019-12-11 04:18:27
问题 The following code when executed using w3schools' interactive js environment (here): var d1=new Date(1306796400000); document.write("Original form: " + d1); displays the following message: Original form: Tue May 31 2011 00:00:00 GMT+0100 (GMT Daylight Time) But this: var d1=new Date(1231977600000); document.write("Original form: " + d1); displays this message: Original form: Thu Jan 15 2009 00:00:00 GMT+0000 (GMT Standard Time) I thought that the millisecond value was just milliseconds since

How to render local time given UTC datetime values in ASP.Net without using Javascript?

心不动则不痛 提交于 2019-12-11 03:15:22
问题 Is it possible to display local times to users without using Javascript when you store the values as UTC? 回答1: You would need serverside to be aware of the clients timezone. There isn't enough information in the typical request to make that determination, the closest you can get is the Accept_Language header which might give you a clue but is hardly useful enough (esp. if the client is in a country that has multiple timezones). Hence you would need to user to tell you what their timezone is

Python datetime and utc offset conversion ignoring timezone/daylight savings

眉间皱痕 提交于 2019-12-11 03:11:25
问题 I have two operations I want to perform, one the inverse of the other. I have a UNIX timestamp at UTC, say for instance, 1425508527. From this I want to get the year, month, day etc. given a UTC offset. EG. what is the year/month/day/time in (UTC -6 hours)? The answer is March 4, 2015 at 16:35:27. Without providing an offset (or offset zero) the answer should be March 4, 2015 at 22:35:27. Now I have the date at some location, along with the UTC offset. For instance March 4, 2015 at 16:35:27

Java utc milliseconds

允我心安 提交于 2019-12-11 02:46:26
问题 Trying to get Universal Time in java seems to be so difficult. Something like this in C# DateTime.Now.ToUniversalTime() seems to be something so difficult. I have code that subtracts a current utc time from a earlier date that is also utc to find the difference in time. But I can't seem to see how to get the current utc time. this is my current code Date date = new Date(); long difference = date.getTime() - s.getTime(); s is already in utc time because it comes from a source that is passing

Difference between moment.utc(date) and moment(date).utc()

一曲冷凌霜 提交于 2019-12-11 02:34:25
问题 Trying to understand the behaviour and difference between: moment.utc(date) and moment(date).utc() Using '2018-05-31' as a param: moment.utc('2018-05-31').format() will give: ‌2018-05-31T00:00:00Z while moment('2018-05-31').utc().format() will give: 2018-05-31T04:00:00Z I am executing both in EST timezone. 回答1: The first moment.utc(String) parses your string as UTC, while the latter converts your moment instance to UTC mode. By default, moment parses and displays in local time. If you want to