timezone-offset

Converting GMT time to local time using timezone offset, not timezone identifier

不羁岁月 提交于 2020-01-06 07:57:13
问题 It's pretty easy to convert a given GMT date into local time if you're given the timezone identifier from this list in PHP: http://www.php.net/manual/en/timezones.php For example, you can do this (where $fromTimeZone is just 'GMT', $toTimeZone is just one of the constants from that list (i.e. 'America/Chicago'), and $datetime is the GMT date): public static function convertToTimezone($datetime, $fromTimeZone, $toTimeZone, $format = 'Y-m-d H:i') { // Construct a new DateTime object from the

Convert cron expression from one timezone to another one

为君一笑 提交于 2020-01-04 03:58:09
问题 I am looking for the way to convert cron expression from one timezone to another one timezone. For example, my web-client user is GMT+1200 and my server-side is GMT+0800, while user setting 02:10 to execute task every Tuesday and Thursday, the cron expression will be "0 10 2 3,5 * ?", and I have used code as below, it can get current fire time for user's timezone CronExpression expr = new CronExpression("0 10 2 3,5 * ?"); System.out.println(expr.getNextValidTimeAfter(new Date())); System.out

Daylight Saving Time start and end dates in Ruby/Rails

主宰稳场 提交于 2020-01-02 04:36:29
问题 I'm working on a Rails app where I need to find the Daylight Saving Time start and end dates given a specific offset or timezone. I basically save in my database the timezone offset received from a user's browser( "+3" , "-5" ) and I want to modify it when it changes because of daylight saving time. I know Time instance variables have the dst? and isdst methods which return true or false if the date stored in them is in the daylight saving time or not. > Time.new.isdst => true But using this

moment.js, timezones and daylight savings

北战南征 提交于 2020-01-02 02:01:35
问题 I return a list of UTC dates/times from a .Net service, formatted like so: "2013-07-09 19:48:07 +00:00". On the client, I convert each of these string values into a corresponding UTC-based moment, like so var fooUtc = new moment.utc(serverDateTimeString) On the page, there is a droop-down containing a list of time-zones that the user can change. These are tied to a collection of time-zone objects like the following: { id: "Central Standard Time", label: "(UTC-06:00) Central Time (US & Canada)

moment.js, timezones and daylight savings

南楼画角 提交于 2020-01-02 02:00:05
问题 I return a list of UTC dates/times from a .Net service, formatted like so: "2013-07-09 19:48:07 +00:00". On the client, I convert each of these string values into a corresponding UTC-based moment, like so var fooUtc = new moment.utc(serverDateTimeString) On the page, there is a droop-down containing a list of time-zones that the user can change. These are tied to a collection of time-zone objects like the following: { id: "Central Standard Time", label: "(UTC-06:00) Central Time (US & Canada)

Java 8 timezone conversions

若如初见. 提交于 2019-12-28 02:10:10
问题 In Java 8, I want to convert a datetime from UTC to ACST (UTC+9:30). input -> 2014-09-14T17:00:00+00:00 output-> 2014-09-15 02:30:00 String isoDateTime = "2014-09-14T17:00:00+00:00"; LocalDateTime fromIsoDate = LocalDateTime.parse(isoDateTime, DateTimeFormatter.ISO_OFFSET_DATE_TIME); ZoneOffset offset = ZoneOffset.of("+09:30"); OffsetDateTime acst = OffsetDateTime.of(fromIsoDate, offset); System.out.println(acst.toString()); // 2014-09-14T17:00+09:30 System.out.println(acst.format

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

Get users current time in php with their lat/long/city

你。 提交于 2019-12-24 14:13:33
问题 I'm using http://ipinfodb.com/ api in order to get users lat/long... I have users timezone in the format of an array. The array returns the following information... array(11) { ["statusCode"]=> string(2) "OK"... ["countryCode"]=> string(2) "CA" ["countryName"]=> string(6) "CANADA" ["regionName"]=> string(16) "BRITISH COLUMBIA" ["cityName"]=> string(8) "VANCOUVER" .... ["timeZone"]=> string(6) "-07:00" } With the information from the array, how would i find the users current time when i have

In Postgresql, how to un-invert the timezone offsets with “At Time Zone”

久未见 提交于 2019-12-23 13:07:56
问题 I'm trying to wrap my head around Postgresql timezones, and I can't seem to figure this out. EST is "Eastern Standard Time" in America, and is typically UTC-5. Example 1: Base Test select '08/31/2011 12:00 pm EST'::timestamptz at time zone 'EST'; timezone --------------------- 2011-08-31 12:00:00 Example 2: Offset is +5 select '08/31/2011 12:00 pm EST' at time zone '+5'; timezone --------------------- 2011-08-31 12:00:00 Example 3: Offset is -5 select '08/31/2011 12:00 pm EST' at time zone '

timezone aware date_trunc function

橙三吉。 提交于 2019-12-23 06:55:23
问题 The following query SELECT the_date FROM date_trunc('day', timestamp with time zone '2001-01-1 00:00:00+0100') as the_date results to the_date 2000-12-31 00:00 Is there a way to tell date_trunc to do day/month/year conversions based on the timezone it is feeded with? The expected output would be: 2001-01-1 00:00+0100 回答1: You need to specify at which time zone you want it to show select date_trunc( 'day', timestamp with time zone '2001-01-1 00:00:00+0100' at time zone '-02' ) as the_date; the