timezone

How to format a datetime to GMT irrespective of regional settings?

*爱你&永不变心* 提交于 2019-12-23 06:03:08
问题 I have a datetime stored in the database as GMT. I need to format this datetime as a string together with the timezone offset to UTC, for example: DateTime date = DateTime.Parse("2012-03-15 12:49:23"); string dateAsString = date.ToString("yyyy-MM-ddTHH:mm:ss.fffzzz"); 2012-03-15T12:49:23.000+00:00 This code works on my machine in the UK. When I change my regional settings to a different time zone, for example Perth, I get the following output: 2012-03-15T12:49:23.000+08:00 I need the string

How to format a datetime to GMT irrespective of regional settings?

我的未来我决定 提交于 2019-12-23 06:01:10
问题 I have a datetime stored in the database as GMT. I need to format this datetime as a string together with the timezone offset to UTC, for example: DateTime date = DateTime.Parse("2012-03-15 12:49:23"); string dateAsString = date.ToString("yyyy-MM-ddTHH:mm:ss.fffzzz"); 2012-03-15T12:49:23.000+00:00 This code works on my machine in the UK. When I change my regional settings to a different time zone, for example Perth, I get the following output: 2012-03-15T12:49:23.000+08:00 I need the string

How to convert time to date in the local timezone during query

和自甴很熟 提交于 2019-12-23 05:44:07
问题 We have a very simple payments model with the default "created_at" datetime field that we have to search in a date range so I did this: >> Payment.all(:conditions => ["Date(payments.created_at) >= ? and Date(payments.created_at) <= ?", start_date, end_date]) I'm having an issue with the Date function. For example >> Payment.find(2577).created_at => Thu, 15 Dec 2011 18:15:00 UTC +00:00 But >> Payment.find(2577).created_at.localtime => Fri Dec 16 01:15:00 +0700 2011 So when we search for

Changing time zones with POSIXct time series, R

喜你入骨 提交于 2019-12-23 05:37:06
问题 I've run into a trouble working with time series & zones in R, and I can't quite figure out how to proceed. I have an time series data like this: df <- data.frame( Date = seq(as.POSIXct("2014-01-01 00:00:00"), length.out = 1000, by = "hours"), price = runif(1000, min = -10, max = 125), wind = runif(1000, min = 0, max = 2500), temp = runif(1000, min = - 10, max = 25) ) Now, the Date is in UTC-time. I would like to subset/filter the data, so for example I get the values from today (Today is

Why does MySQL CONVERT_TZ alter the seconds after timezone adjustment?

六眼飞鱼酱① 提交于 2019-12-23 05:33:37
问题 I'm storing UTC datetime values in MySQL. I use CONVERT_TZ to handle timezone conversion to query/save local datetimes to/from UTC in the database. Upon testing I noticed this strange peculiarity in how the conversion works. Can anyone explain why it is MySQL is adding 23 seconds when using the -4:00 hour offset, but not when using the equivalent timezone label? select convert_tz('2009-06-12 01:00:00', 'UTC', '-4:00') 2009-06-11 21:00:23 select convert_tz('2009-06-12 01:00:00', 'UTC', 'US

Date and time handling in applications serving clients in multiple time-zones?

本小妞迷上赌 提交于 2019-12-23 05:17:17
问题 The internationalization problems associated with string handling can pretty much be solved by following the advice: use Unicode and store everything as UTF-8 in your database, then you'll be able to serve clients using all the world's languages. But what about the internationalization problems associated with date/time handling? Questions: Are there similar easy-to-follow best practices for solving the internationalization issues surrounding time handling? How do you make sure your

Using 2 Calendar class instances to get time difference

≯℡__Kan透↙ 提交于 2019-12-23 04:43:47
问题 I am using the Calendar library within Java to try and figure out a problem with my application: I have two Calendar instances, depart and arrive . depart is leaving at 5:35 pm on 7/15/2015 from Chicago, while arrive is landing at 9:50 am on 7/16/15 in Berlin, Germany. My current code to display the travel duration is: Calendar depart = Calendar.getInstance(); Calendar arrive = Calendar.getInstance(); depart.setTimeZone(TimeZone.getTimeZone("America/Chicago")); arrive.setTimeZone(TimeZone

Java - Store GMT time

二次信任 提交于 2019-12-23 04:38:34
问题 My server has GMT+7, so if i move to another server has another GMT timezone, all date stored in db will incorrect? Yes Q1 is correct, how about i will store date in GMT+0 timezone and display it in custom GMT timezone chosen by each member How i get date with GMT+0 in java 回答1: 1) To quote from the javadocs, Java millisecond timestamps are the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC. Therefore, as the timestamp is UTC/GMT, if you store

Is getTimezoneOffset() stable during daylight saving transition?

笑着哭i 提交于 2019-12-23 04:31:49
问题 I have date time below conversion logic in Javascript which is converting the UTC time into passed timezone's local time. I am wondering this logic will work fine during Daylight transition? If not what is the remedy for that? I can't use any third party library. I have to use pure javascript or Angular JS. function myTime() { var d1= document.getElementById("txtDate").value; var zOffset = document.getElementById("txtOffset").value; console.log("Date1",d1); var d2 = new Date(d1.replace(/ /g,

Is getTimezoneOffset() stable during daylight saving transition?

夙愿已清 提交于 2019-12-23 04:31:45
问题 I have date time below conversion logic in Javascript which is converting the UTC time into passed timezone's local time. I am wondering this logic will work fine during Daylight transition? If not what is the remedy for that? I can't use any third party library. I have to use pure javascript or Angular JS. function myTime() { var d1= document.getElementById("txtDate").value; var zOffset = document.getElementById("txtOffset").value; console.log("Date1",d1); var d2 = new Date(d1.replace(/ /g,