timezone-offset

What is the best way to store timezone information in my DB?

十年热恋 提交于 2019-11-29 11:17:53
问题 I have a asp.net-mvc web site that i took over and there is a page page where people enter information and times (including local timezone). The database is persisting a start time, an end time and a timezone as it feels a bit flaky to me. here is the code to get the list to choose from: static private IEnumerable<SelectListItem> GetTimeZones(string selected) { var timeZoneNames = TimeZoneInfo.GetSystemTimeZones() .Where(tz => tz.DisplayName.Contains("London") || tz.DisplayName.Contains("Hong

Why UTC (which is not a time zone) is considered as a time zone in Java (and not only there)?

痞子三分冷 提交于 2019-11-29 10:19:56
Given that UTC is not a time zone, but a time standard (as stated, for example, here ), why in my Java application I can use UTC as if it was a time zone (see the code snippet below)? SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); format.setTimeZone(TimeZone.getTimeZone("UTC")); If UTC is not a time zone, why is TimeZone.getTimeZone("UTC") able to return the time zone object? By the way, on my Windows machine UTC is in the list of time zones also (see the screenshot). Is the statement "UTC is not a time zone" in reality wrong? Is the statement "UTC is not a time zone"

Get timezone difference in hours with moment

一个人想着一个人 提交于 2019-11-29 09:38:40
I would like to get the timezone difference between New York and Hong Kong with Node.js moment module. I have done some preliminary work. var NewYork_time_hr = moment().tz("America/New_York").format('HH'); var HongKong_time_hr = moment().tz("Asia/Hong_Kong").format('HH'); I can then proceed to write a function to calculate the difference between the 2 timezones in hours. I was hoping for a simpler method. Is there a more elegant and simpler way to do it with moment library? Not sure about "simpler", but more correct (since not all timezones are a full hour from each other): // get the current

How to get default ZoneOffset in java8?

南笙酒味 提交于 2019-11-28 16:40:22
问题 With java8 we know use ZoneId.default() can get system default ZoneId , but how to get default ZoneOffset ? I see that a ZoneId has some "rules" and each rule has a ZoneOffset , is that means a ZoneId may have more than one ZoneOffset ? 回答1: tl;dr OffsetDateTime.now().getOffset() But you likely should be using a time zone rather than a mere offset-from-UTC. ZoneId.systemDefault() Offset versus Time Zone An offset-from-UTC is merely a number of hour, minutes, and seconds — nothing more. For

How to construct time.Time with timezone offset [duplicate]

左心房为你撑大大i 提交于 2019-11-28 10:57:51
问题 This question already has an answer here: How do you convert a time offset to a location/timezone in Go 2 answers This is an example date from an Apache log: [07/Mar/2004:16:47:46 -0800] I have successfully parsed this into year(int), month(time.Month), day(int), hour(int), minute(int), second(int), and timezone(string). How can I construct time.Time such that it includes the -0800 time zone offset? This is what I have so far: var nativeDate time.Time nativeDate = time.Date(year, time.Month

Why does JavaScript Date.getTimezoneOffset() consider “-05:00” as a positive offset?

▼魔方 西西 提交于 2019-11-28 05:42:44
I noticed that for us on Eastern Time zone ("America/New_York") with timezone offset of "-05:00" Date.getTimezoneOffset() returns a positive number of 300. I would expect offset in minutes to be negative in areas to the West from Utc, and to be positive in areas to the east of Utc, but apparently it's "flippded". What's the reasoning behind that decision? http://momentjs.com/ follows the same rule and returns... moment.parseZone("01/13/2014 3:38:00 PM +01:00").zone() // == -60 moment.parseZone("01/13/2014 3:38:00 PM -01:00").zone() // == 60 At the same time DateTimePicker http:/

UNIX timestamp(0): Europe/London returns UTC+1

时光怂恿深爱的人放手 提交于 2019-11-28 04:28:21
问题 Learning dates and they're giving me hard time right now. $london = new DateTime(); $london->setTimestamp(0); $london->setTimeZone(new DateTimeZone('Europe/London')); echo $london ->format('d-m-Y H-i-s'); result: 01-01-1970 01-00-00 Shouldn't be London in UTC +0:00 therefore midnight? For example, New York returns 19:00 of the previous date which is correctly UTC -5:00 . Moscow returns 01-01-1970 03-00-00 which is again incorrect ( UTC +3:00 as opposed to UTC +4:00 ) When not using -

Determine my time zone offset using VBScript?

有些话、适合烂在心里 提交于 2019-11-28 04:19:48
问题 How can I determine my time zone offset using VBScript ? The Windows OS provides the TZ environment variable. For Eastern Standard Time (New York), its value is EST5EDT . However, I am looking for the signed integer offset from UTC. (This is -5 for Eastern Standard Time.) 回答1: Here is a revised function that appears to account for Daylight Saving Time. (Inspired by this SO question.) Function GetTimeZoneOffset() Const sComputer = "." Dim oWmiService : Set oWmiService = _ GetObject("winmgmts:

Why UTC (which is not a time zone) is considered as a time zone in Java (and not only there)?

只谈情不闲聊 提交于 2019-11-28 03:43:50
问题 Given that UTC is not a time zone, but a time standard (as stated, for example, here), why in my Java application I can use UTC as if it was a time zone (see the code snippet below)? SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); format.setTimeZone(TimeZone.getTimeZone("UTC")); If UTC is not a time zone, why is TimeZone.getTimeZone("UTC") able to return the time zone object? By the way, on my Windows machine UTC is in the list of time zones also (see the screenshot).

Get timezone difference in hours with moment

梦想与她 提交于 2019-11-28 03:05:43
问题 I would like to get the timezone difference between New York and Hong Kong with Node.js moment module. I have done some preliminary work. var NewYork_time_hr = moment().tz("America/New_York").format('HH'); var HongKong_time_hr = moment().tz("Asia/Hong_Kong").format('HH'); I can then proceed to write a function to calculate the difference between the 2 timezones in hours. I was hoping for a simpler method. Is there a more elegant and simpler way to do it with moment library? 回答1: Not sure