timezone

Joda Time converting time zoned date time to milliseconds

旧时模样 提交于 2019-12-30 03:43:28
问题 Can somebody please explain to me why when I try to get the milliseconds of a DateTime with a zone different from my own, it gives me back the milliseconds of my local machine's time zone? I'm looking to get the milliseconds of UTC, but my local settings of the application are set to EST (even though I'm actually in Ireland ;) ) Here's the code: DateTimeFormatter format = DateTimeFormat.mediumDateTime(); DateTime local = new DateTime(); DateTime utc = new DateTime(System.currentTimeMillis(),

Correcting time for daylight savings in rails DateTime.parse

给你一囗甜甜゛ 提交于 2019-12-30 02:45:11
问题 Just adding to the million questions about time zone and DST issues out there. I have a form with separate date and time fields that I combine to create a DateTime like so start_time = DateTime.parse("#{parse_date(form_date)} #{form_start_time} #{Time.zone}") If I fill out my form with 21 Aug 2012 and 15:00, then these are the values that I see when I reload my form. If I then look at my start_time attribute in my model it is correctly set to Tue, 21 Aug 2012 15:00:00 EST +10:00 . The problem

C#: Making sure DateTime.Now returns a GMT + 1 time

情到浓时终转凉″ 提交于 2019-12-30 00:00:14
问题 I am using DateTime.Now to show something according to today's date, and when working locally (Malta, Europe) the times appear correctly (obviously because of the Time Zone) but ofcourse when I upload it to my hosting server (USA), DateTime.Now does not represent the correct time zone. Therefore, in my code, how can I convert DateTime.Now to correctly return the time from a GMT + 1 timezone ? 回答1: Use the TimeZoneInfo class found in System.Core; You must set the DateTimeKind to DateTimeKind

DateTime::diff() isn't affected by timezone but always return same value

青春壹個敷衍的年華 提交于 2019-12-29 09:36:20
问题 I am adding auction-based data to my system. For example: user's timezone is : `America/Denver` auction start time is : Thu, 21 Jun 2012 03:46:22 AM auction period : 1 day. auction end time : Fri, 22 Jun 2012 03:46:22 AM I store all these information as it is in my DB (i.e. all stored time based on user's timezone ). Now I want the actual difference between end time and current time (of America/Denver timezone). I used DateTime() functions so even I don't convert the timezone; it returns same

Can we change the device time using an application?

时光怂恿深爱的人放手 提交于 2019-12-29 09:05:21
问题 Want to know whether its possible to change the time of the iPhone through an application.. Is that level of dev access granted in iOS4? My gut feeling is no, but I'm looking for a definitive Yes/No answer if possible. Note: NSTimeZone class states 'Cocoa does not provide any API to change the time zone of the computer, or of other applications.' Thanks.. 回答1: No this functionality is not possible via the official iphone SDK. 来源: https://stackoverflow.com/questions/3121287/can-we-change-the

.NET PCL exception while converting time from UTC to specified TimeZone

孤人 提交于 2019-12-29 08:49:29
问题 I am developing a project in Xamarin Studio using C#. Its a .net PCL project and my profile is 78. My problem is, i am unable to convert a DateTime from UTC to specified timezone. I am using below code to convert DateTime from UTC to specified local TimeZone. DateTime dateTime = (TimeZoneInfo.ConvertTime (DateTime.SpecifyKind (DateTime.UtcNow, DateTimeKind.Utc), profile.TimeZone)); I am getting below exception The Kind property of the dateTime parameter is DateTimeKind.Utc, but the

Angular Moment : Moment Timezone has no data for America/New_York

别说谁变了你拦得住时间么 提交于 2019-12-29 08:27:26
问题 Date received from server is in UTC timezone and I need to convert it to a particular timezone, for example : America/New_York .Following is the code for same <span class="bold" ng-bind="sess.date_time | amTimezone:'America/New_York' | amDateFormat:'h:mm a'"></span> But on doing so I get the following error: Moment Timezone has no data for America/New_York. See http://momentjs.com/timezone/docs/#/data-loading/. But America/New_York is a known timezone to moment but still it is asking me to

How to get local time of different time zones?

為{幸葍}努か 提交于 2019-12-29 07:26:05
问题 I want to get local time of different time zones using Java code. Based on the time zone passed to the function I need that time zone's local time. How to achieve this? 回答1: java.util.TimeZone tz = java.util.TimeZone.getTimeZone("GMT+1"); java.util.Calendar c = java.util.Calendar.getInstance(tz); System.out.println(c.get(java.util.Calendar.HOUR_OF_DAY)+":"+c.get(java.util.Calendar.MINUTE)+":"+c.get(java.util.Calendar.SECOND)); 回答2: I'd encourage you to check out Joda Time, an alternative (but

android timezone difference is 1 hour less then expected

蹲街弑〆低调 提交于 2019-12-29 07:22:26
问题 What I need is a time difference between specific timezone ("Russia/Moscow") and local time of the user, difference should be in hours. I run into problem that the Difference of Time Zones is sometimes false calculated. I calculate difference (in hours) between local offset to UTC of android device and remote offset to UTC. For most user it is fine.. but many user are complaining about the problem.. I am not able to reproduce it at my phone or emulators. The "wrong" displayed time difference

android timezone difference is 1 hour less then expected

女生的网名这么多〃 提交于 2019-12-29 07:21:48
问题 What I need is a time difference between specific timezone ("Russia/Moscow") and local time of the user, difference should be in hours. I run into problem that the Difference of Time Zones is sometimes false calculated. I calculate difference (in hours) between local offset to UTC of android device and remote offset to UTC. For most user it is fine.. but many user are complaining about the problem.. I am not able to reproduce it at my phone or emulators. The "wrong" displayed time difference