utc

How can I determine a timezone by the UTC offset?

大憨熊 提交于 2019-12-28 05:52:05
问题 I have a scenario where I have a timezone offset (in minutes) and need to determine the timezone for it. I know that all the data is not available (for example, there may be several timezones with an offset of -240 minutes) but a "best guess" is acceptable. My first pass looked like this: foreach (var info in TimeZoneInfo.GetSystemTimeZones()) { if (info.BaseUtcOffset.TotalMinutes == timezoneOffset) { // do something here if this is a valid timezone } } This sorta works, but I need to account

DateFormat parse - not return date in UTC

夙愿已清 提交于 2019-12-27 16:05:55
问题 Here my java code that try to get current date in UTC on Android device: public static Date getCurrentDateUTC() { try { TimeZone timeZoneUTC = TimeZone.getTimeZone("UTC"); Date localTime = new Date(); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z"); dateFormat.setTimeZone(timeZoneUTC); String dateUTCAsString = dateFormat.format(localTime); Debug.d(TAG, "getCurrentDateUTC: dateUTCAsString = " + dateUTCAsString); Date dateResult = dateFormat.parse(dateUTCAsString); Debug

Generating a drop down list of timezones with PHP

帅比萌擦擦* 提交于 2019-12-27 11:33:14
问题 Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need help knowing which of these would be the best to attempt to use when trying to get the UTC offset from the user on register. One: <option value="-12">[UTC - 12] Baker Island Time</option> <option value="-11">[UTC - 11] Niue Time, Samoa Standard Time</option> <option value="-10">[UTC - 10] Hawaii

How can ToUniversalTime forecast?

只愿长相守 提交于 2019-12-25 18:18:13
问题 There is a relevant question about how ToUniversalTime works. But the relevant information about time conversions tells me there are relevant databases for time conversion in the past. My question is how can ToUniversalTime forecast and knows when will be the DST change in 2070 for example? 回答1: My question is how can ToUniversalTime forecast and knows when will be the DST change in 2070 for example? It can't. It doesn't have any special insight into the future of what the governments of our

Convert UTC time to Local time of Browser

喜你入骨 提交于 2019-12-25 08:20:18
问题 I am getting UTC time format,I need to change it in Local time of browser.I have tried the following:- var start_time1= new Date(matchData.results[i].start_time); where matchData.results[i].start_time is my UTC time i.e. ISODate("2017-03-09T03:30:00Z") After doing above I am getting: 09:00:00 GMT+0530 (IST) But what I want is like, if local browser time is 9:00 a.m., it gives me the same, i.e. 9:00 a.m. 回答1: Did you just try : var start_time1 = new Date("2017-03-09T03:30:00Z"); console.log

How to deserialize XML attribute of type long to UTC DateTime?

*爱你&永不变心* 提交于 2019-12-25 07:59:18
问题 Following these answers, I've decided to use xsd.exe and XmlSerializer as the most simple way to parse XML. But I want some refinements: My top request is changing MyRoot.Time type from long to DateTime . It can be achieve easily by code using DateTime.FromFileTimeUtc or new DateTime, but can it be done directly by the XmlSerializer? Can I change MyRoot.Children type into something more complex like Dictionary<string,Tuple<int,ChildState>> ? My XML: <Root timeUTC="129428675154617102"> <Child

Format A Date With Offset

让人想犯罪 __ 提交于 2019-12-25 06:08:36
问题 I am attempting to alter a string DateTime value with Offset. This is the procedure I have attempted, but in the end, both datetime & datetime1 print their initial values. My desired output is to format datetime1 to the proper Offset so that it mirrors datetime 01/10/2016 5:18 PM 01/10/2016 5:18 PM-05:00 string datetime = "2017-01-10T17:18:00-05:00"; string datetime1 = "1/10/2016 3:18:00 PM"; DateTimeOffset dateTimeOffset = DateTimeOffset.Parse(datetime); TimeSpan tspan = dateTimeOffset

Convert UTC time to hours, minutes, and AM/PM format in javascript

被刻印的时光 ゝ 提交于 2019-12-25 03:24:46
问题 Given a UTC time, what is a simple way of converting it to a format in hours, minutes, and AM/PM (e.g. '3:30 PM')? 回答1: <script type="text/javascript"> <!-- var a_p = ""; var d = new Date(); var curr_hour = d.getHours(); if (curr_hour < 12) { a_p = "AM"; } else { a_p = "PM"; } if (curr_hour == 0) { curr_hour = 12; } if (curr_hour > 12) { curr_hour = curr_hour - 12; } var curr_min = d.getMinutes(); document.write(curr_hour + " : " + curr_min + " " + a_p); //--> </script> http://www

Datetime module and Pandas to_datetime give different results

♀尐吖头ヾ 提交于 2019-12-24 19:38:46
问题 I have a string containing a UTC datetime utc_str = '2017-11-21T23:00+0100' which in my local time (Europe/Berlin) is: local_time = '2017-11-22 00:00' And is the desired value I would like to obtain from utc_string . I can convert utc_string to local_time just fine using: import datetime as dt utc_time = dt.datetime.strptime(date_str, '%Y-%m-%dT%H:%M%z') local_time = utc_time.replace(tzinfo=pytz.utc).astimezone(pytz.timezone('Europe/Berlin')) print(local_time.strftime('%Y-%m-%d %H:%M')) >>>

Find UTC Time for ALL USA TimeZone for below Times using C#.net

回眸只為那壹抹淺笑 提交于 2019-12-24 19:32:01
问题 How can i find UTC time for all these TimeZone for all these hours 8 Am (in UTC for all USA Time Zones) 5 PM (in UTC for all USA Time Zones) 10 PM (in UTC for all USA Time Zones) USA Time Zones Hawaii Time Alaska Time Pacific Time Mountain Time Central Time Eastern Time I need to find it using C#.net More Details: For all who are curious what am I doing with these times. I have to run a scheduled job at these times 8AM, 5PM and 10PM every day And this time should be user local time. So if I