timezone

django的时区冲突错误 /usr/lib/python2.7/site-packages/...

青春壹個敷衍的年華 提交于 2019-12-18 22:18:52
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 这个错误大概不会影响你的一些主要功能,但是在终端会显示warning的。 错误的原因比较明显,就是 DateTimeField received a naive datetime while time zone support is active. 所谓的数据库中存储DateTimeField类型项的时候,收到一个本地的时间,但是django的时区是动态的(默认一般是US的时区)。 修这个bug很简单,就是在settings.py中,找到,将USE_TZ的值改为False就可以了: # If you set this to False, Django will not use timezone-aware datetimes. USE_TZ = False 来源: oschina 链接: https://my.oschina.net/u/736230/blog/168662

Firefox new Date() from string constructs time in local time zone

回眸只為那壹抹淺笑 提交于 2019-12-18 21:53:44
问题 I am trying to create a date object from a string. I get date in ISO format except milliseconds part like "2012-01-30T16:23:12" Results differ when I run following code in IE, Chrome and Firefox (Link to Fiddle) currentDate = "2012-01-30T16:23:12"; var date = new Date(currentDate); alert(date); IE and Chrome considers the string as UTC but firefox considers in local time zone. Is there any generic way to get around it except for checking user agent everywhere? 回答1: You could try appending the

Java - Creating a Calendar without a TimeZone

孤者浪人 提交于 2019-12-18 17:36:31
问题 I would like to start by saying that I've read several threads similar to this one, but none of them really solved my problem. I would also like to state that I've tried to use SimpleDateFormat and joda.DateTime without any success. The problem is the following: I have a Calendar object that holds the information about a specific date: 2008-04-30T00:00:00Z When using the calendar.getTime() method I can get different results because I know that that method is looking for the local value Thus:

What's the best way to manage dates across PHP, MySQL, etc?

假如想象 提交于 2019-12-18 17:14:11
问题 My server is in Dallas. I'm in New York City.. and both PHP and MySQL have configuration variables for setting the timezone. How do I get them all to work together? What dates should I store in MySQL? How do I get PHP to handle changing the date based on the user's preference? Bear in mind: I don't think I'm ever having PHP explicitly set the date, it's always using "NOW()" in queries.. however I foresee the need to do this. How would this be done? I'm hoping SO's experience can help me out

Rails app config.time_zone not applying when populating form fields for '/edit' view

不问归期 提交于 2019-12-18 17:05:55
问题 I specified config.time_zone in my Rails app, but the retrieved times in form fields still render as the UTC (which creates problems on updates). Shouldn't this be converted to local time in the specified zone? /config/application.rb (relevant lines only): module ExampleSite class Application < Rails::Application config.time_zone = 'Central Time (US & Canada)' end end /events/edit.html.erb (full file): <h1>Edit This Event</h1> <%= form_for(@event) do |f| %> <%= render 'fields', :f => f %>

Writing ICS files for multiple clients, including Google

点点圈 提交于 2019-12-18 16:30:13
问题 I need to write a script for publishing .ICS files. I've read that it's difficult to do this right, either because some calendar clients are buggy (lots of people claim Google Calendar is extremely buggy especially regarding time zones) or because developers aren't following the spec properly. I only need to do this for North America but I do have to account for DST (keeping in mind places like Arizona, parts of which observe DST and parts of which don't). Can anyone answer these questions?

Android how to get time difference between two time zones in android?

你。 提交于 2019-12-18 15:36:10
问题 I need to get time difference between two dates in different time zones. Currently I am doing this: Calendar c1=Calendar.getInstance(TimeZone.getTimeZone("EDT")); Calendar c2=Calendar.getInstance(TimeZone.getTimeZone("GMT")); String diff=((c2.getTimeInMillis()-c1.getTimeInMillis())/(1000*60*60))+" hours"; new AlertDialog.Builder(this).setMessage(diff).create().show(); I get 0 hours. What am I doing wrong? 回答1: getTimeInMillis() returns the number of milliseconds since the epoch in UTC . In

Android how to get time difference between two time zones in android?

拟墨画扇 提交于 2019-12-18 15:36:08
问题 I need to get time difference between two dates in different time zones. Currently I am doing this: Calendar c1=Calendar.getInstance(TimeZone.getTimeZone("EDT")); Calendar c2=Calendar.getInstance(TimeZone.getTimeZone("GMT")); String diff=((c2.getTimeInMillis()-c1.getTimeInMillis())/(1000*60*60))+" hours"; new AlertDialog.Builder(this).setMessage(diff).create().show(); I get 0 hours. What am I doing wrong? 回答1: getTimeInMillis() returns the number of milliseconds since the epoch in UTC . In

How to handle times with a time zone in Matplotlib?

China☆狼群 提交于 2019-12-18 15:17:06
问题 I have data points whose abscissas are datetime.datetime objects with a time zone (their tzinfo happens to be a bson.tz_util.FixedOffset obtained through MongoDB). When I plot them with scatter() , what is the time zone of the tick labels? Changing the timezone in matplotlibrc does not change anything in the displayed plot (I must have misunderstood the discussion on time zones in the Matplotlib documentation). I experimented a little with plot() (instead of scatter() ). When given a single

Convert Timestamp to Timezones

為{幸葍}努か 提交于 2019-12-18 15:00:16
问题 I have a timestamp the user enters in GMT. I would then like to display that timestamp in gmt, cet, pst, est. Thanks to the post below I have made, which works perfectly! public static function make_timezone_list($timestamp, $output='Y-m-d H:i:s P') { $return = array(); $date = new DateTime(date("Y-m-d H:i:s", $timestamp)); $timezones = array( 'GMT' => 'GMT', 'CET' => 'CET', 'EST' => 'EST', 'PST' => 'PST' ); foreach ($timezones as $timezone => $code) { $date->setTimezone(new DateTimeZone(