timezone

Changing current user timezone based on server UTC offset and user UTC offset

江枫思渺然 提交于 2020-01-01 05:50:09
问题 im writing a twitter web service in php. When a user signs in, i receive this node: <utc_offset>-18000</utc_offset> I have to change the script's timezone so that it adapts to the user's real timezone. The only php function i have found for this is: date_default_timezone_set($timezone_identifier) but it won't let me use -18000 as a the $timezone_identifier parameter. So, how can i change the current user timezone based on two values: Server UTC offset and User UTC offset BTW, this is how i'm

How to handle JodaTime's and Android's timezone database differences?

删除回忆录丶 提交于 2020-01-01 05:43:09
问题 I want to extend a discussion I started on the Reddit Android Dev community yesterday with a new question: How do you manage an up-to-date timezone database shipped with your app using the JodaTime library on a device that has outdated timezone information? The problem The specific issue at hand relates to a particular timezone, "Europe/Kaliningrad". And I can reproduce the problem: On an Android 4.4 device, if I manually set its time zone to the above, calling new DateTime() will set this

DateTime constructor in php

妖精的绣舞 提交于 2020-01-01 05:29:04
问题 I have done a little experiment on php's DateTime class. In the documentation they have suggested the syntax for creating the object of DateTime class as given. Object oriented style: public DateTime::__construct() ( [ string $time = "now" [, DateTimeZone $timezone = NULL ]] ) Procedural style: DateTime date_create ( [ string $time = "now" [, DateTimeZone $timezone = NULL ]] ) Returns new DateTime object. Here the first argument they have specified as mandatory, as a date/time string as

Rails:How to create a time column with timezone on postgres

时光毁灭记忆、已成空白 提交于 2020-01-01 04:25:09
问题 I have a rails application which works on postgres db. I have a model called UserTimings where there are two fields from_time and to_time. t.time "from_time" t.time "to_time" I expected that the time will be stored in complete UTC format with timezone information. After a little while, I realized that the database has this kind SQL query to create the table. from_time time without time zone, to_time time without time zone, I do not want this. I want to store with time zone . I want the +0530

Python datetime not including DST when using pytz timezone

杀马特。学长 韩版系。学妹 提交于 2020-01-01 04:17:24
问题 If I convert a UTC datetime to swedish format, summertime is included (CEST). However, while creating a datetime with sweden as the timezone, it gets CET instead of CEST. Why is this? >>> # Modified for readability >>> import pytz >>> import datetime >>> sweden = pytz.timezone('Europe/Stockholm') >>> >>> datetime.datetime(2010, 4, 20, 16, 20, tzinfo=pytz.utc).astimezone(sweden) datetime(2010, 4, 20, 18, 20, tzinfo=<... 'Europe/Stockholm' CEST+2:00:00 DST>) >>> >>> datetime.datetime(2010, 4,

Using Joda-Time to get UTC offset for a given date and timezone

会有一股神秘感。 提交于 2020-01-01 04:12:09
问题 I have dates in the format 20Jan2013, 08Aug2012 etc, with their own specific timezones. So for example, 20Jan2013 might have a timezone ID of Australia/Melbourne, and 08Aug2012 might have an ID of Europe/London. What I want to do is, based on these timezones and the dates, calculate the UTC offset for that timezone on the given date. I've come up with this so far: DateTimeFormatter dtf = DateTimeFormat.forPattern("ZZ"); DateTimeFormatter dtf1 = DateTimeFormat.forPattern("ddMMMYYYY");

Format Timezone for Carbon Date

本小妞迷上赌 提交于 2020-01-01 03:54:08
问题 I'm trying to set the timezone for a date in a Carbon object. It works fine locally but on my production box it keeps giving me Bad timezone error. I've tried: $date->setTimezone('7'); $date->setTimezone('+7'); $date->setTimezone('7:00'); $date->setTimezone('+7:00'); $date->setTimezone('UTC 7'); $date->setTimezone('UTC +7'); $date->setTimezone('UTC 7:00'); $date->setTimezone('UTC +7:00'); No idea why it's complaining on my production box. Can't find documentation either on what is the "proper

Convert NSDate to NSString with NSDateFormatter with TimeZone without GMT Time Modifier

爷,独闯天下 提交于 2020-01-01 01:18:14
问题 I'm initializing my NSDateFormatter thusly: NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]]; [dateFormatter setDateFormat:@"EEE, d MMM yyyy HH:mm:ss z"]; [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; NSDate *date = [NSDate date]; NSString *dateString = [dateFormatter stringFromDate:date]; dateString is now: Thu, 29 Jul 2010 14:58:42 GMT+00

How can I recognize the Zulu time zone in Java DateUtils.parseDate?

主宰稳场 提交于 2019-12-31 21:44:56
问题 I have dates in the format 2008-12-23T00:00:00Z . This look a lot like a ISO 8601 format with a Zulu (UTC) timezone. I though the following code would parse it (using commons-lang) : String pattern = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern(); Date d = DateUtils.parseDate(dateToParse, new String[] { pattern }); If I take the same pattern ( yyyy-MM-dd'T'HH:mm:ssZZ ) but remove the timezone, it works. Do you know how I can recognize the Zulu timezone ? I have access only to Java

How do I set the timezone in Tomcat for a single web app?

穿精又带淫゛_ 提交于 2019-12-31 20:06:12
问题 What is the best way to set the time zone in Tomcat for a single web app? I've seen options for changing the command-line parameters or environment variables for Tomcat, but is there a way to set it that is self-contained in the WAR file and not dependent on any Tomcat configuration? Edit: to reemphasize, I'm looking for a solution that can be contained within a WAR file, not dependent on Tomcat configuration. To put it another way, can one web app be configured to have a different time zone