timezone

Dealing with PHP server and MySQL server in different time zones

我与影子孤独终老i 提交于 2019-12-17 23:36:44
问题 For those of us who use standard shared hosting packages, such as GoDaddy or Network Solutions, how do you handle datetime conversions when your hosting server (PHP) and MySQL server are in different time zones? Also, does anybody have some best practice advice for determining what time zone a visitor to your site is in and manipulating a datetime variable appropriately? 回答1: As of PHP 5.1.0 you can use date_default_timezone_set() function to set the default timezone used by all date/time

python: datetime tzinfo time zone names documentation

半城伤御伤魂 提交于 2019-12-17 23:27:19
问题 I have a date that I build: from datetime import datetime from datetime import tzinfo test = '2013-03-27 23:05' test2 = datetime.strptime(test,'%Y-%m-%d %H:%M') >>> test2 datetime.datetime(2013, 3, 27, 23, 5) >>> test2.replace(tzinfo=EST) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'EST' is not defined >> test2.replace(tzinfo=UTC) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'UTC' is not defined I can't find

Set current Time.zone in Rails?

余生长醉 提交于 2019-12-17 23:08:06
问题 Javascript on my page saves client UTC offset to the cookie. How do I use this cookie to create a TimeZone and assign it to Time.zone ? I need something like: before_filter :set_time_zone def set_time_zone Time.zone = ActiveSupport::TimeZone.new('my timezone', cookies[:timezone]) end except that the right part of this expression does not work and I'm not sure if I'm going the right way here. Can't get it. 回答1: Here's the working googled answer: min = cookies[:timezone].to_i Time.zone =

date_default_timezone_get(): It is not safe to rely on the system's timezone settings

吃可爱长大的小学妹 提交于 2019-12-17 22:45:17
问题 Can anyone tell me why am I getting this error when running app/console in a brand new formatted macbook with the latest MAMP installed ? Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for

How to check is timezone identifier valid from code?

偶尔善良 提交于 2019-12-17 22:28:21
问题 I'll try to explain what's the problem here. According to list of supported timezones from PHP manual, I can see all valid TZ identifiers in PHP. My first question is how to get that list from code but that's not what I really need. My final goal is to write function isValidTimezoneId() that returns TRUE if timezone is valid, otherwise it should return FALSE . function isValidTimezoneId($timezoneId) { # ...function body... return ?; # TRUE or FALSE } So, when I pass TZ identifier using

How to clear TimeZoneInfo cache in WinRT?

泄露秘密 提交于 2019-12-17 21:20:27
问题 In .NET some values used by TimeZoneInfo are cached, such as the current time zone in use by TimeZoneInfo.Local , DateTime.ToLocalTime , etc. In traditional .NET framework apps, this cache can be cleared by calling TimeZoneInfo.ClearCachedData() , as explained in the docs. However, in WinRT applications, such as Windows Store apps, and Windows Universal Apps, the ClearCachedData API is not available. How do you clear the time zone cache in a WinRT environment? 回答1: There's an undocumented way

HTML Input type datetime-local setting the wrong time-zone

泄露秘密 提交于 2019-12-17 20:52:17
问题 I've created an app that takes in HTML inputs and goes through JavaScript to create an event on a native calendar events. It takes the time from the <input type="datetime-local"> , and it's putting in a different time because it's picking a different time zone. If I enter 1 o'clock PM as a time it will return 8 o'clock AM. <input type="datetime-local" id="startDate" name="startDate"> And the JavaScript: var startDate = new Date($("#startDate").val()); Any help would be awesome. I can post

What is the System.TimeZoneInfo.IsDaylightSavingTime equivalent in NodaTime?

泄露秘密 提交于 2019-12-17 20:49:47
问题 System.TimeZoneInfo has a method called IsDaylightSavingTime, which takes a DateTime object and returns true if the specified datetime falls in the DST for that timezone. Is there an equivalent function in NodaTime or another way to achieve the same result? 回答1: You can get this from a ZoneInterval . Here is an extension method that will help. public static bool IsDaylightSavingsTime(this ZonedDateTime zonedDateTime) { var instant = zonedDateTime.ToInstant(); var zoneInterval = zonedDateTime

Javascript/PHP and timezones

不问归期 提交于 2019-12-17 20:36:19
问题 I'd like to be able to guess the user's timezone offset and whether or not daylight savings is being applied. Currently, the most definitive code that I've found for this is here: http://www.michaelapproved.com/articles/daylight-saving-time-dst-detect/ So this gives me the offset along with the DST indicator. Now, I want to use these in my PHP scripts in order to ouput the local date/time for the user....but what's best for this? I figure I have 2 options: a) Pick a random timezone which has

How to change Tomcat 7's server timezone?

半城伤御伤魂 提交于 2019-12-17 19:58:18
问题 My application deployed in a Debian vps in US, Los Angeles. So code like new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()) will return current time of America/Los Angeles. Can I do some setting in Tomcat's configuration file ( server.xml or catalina.sh or what?) so that get current time will return a specified TimeZone like GMT+8 or Asia/Taipei ??? 回答1: With all of the different places where you can set timezones, it's (in general) always best to explicitly set the timezone when you