Guys
The UK is currently on British Summer Time (BST) so
2014-08-30 16:00:00 BST
2014-08-30 11:00:00 Toronto (Summer)
Greenwich Mean Time (GMT) as a term is not used as frequently as
previously. The preferred term is Universal Coordinated Time (UTC), as
some overseas users confusingly equate GMT with the current time in
Britain, after any adjustment for summer time.
Robin St.Clair
On 20/08/2014 13:32, Geoffrey S. Knauth wrote:
|2014-08-30 16:00:00+00:00 GMT|
|2014-08-30 12:00:00-04:00Toronto (Summer)|
||
||This looks correct to me. Maybe you were expecting the timezone to
be -05:00? That would be standard time (winter). Daylight savings
time is -04:00.
--
Geoffrey S. Knauth | http://knauth.org/gsk
On Wed, Aug 20, 2014, at 08:22, christophw wrote:
Hi there,
I'm feeling some pain while wrangling with timezones in an office
room booking application. I'm storing bookings in a MySQL database
and want to display them in the timezone local to the office room, so
it is not necessarily local to the user's local machine timezone.
Here is my model's datetime definition:
|
classBooking(models.Model):
date_time =models.DateTimeField()
|
When the booking is stored, it comes back from a post and I store it
in the DB as such:
|
dt =datetime.datetime.strptime(request.POST["date"]+"
"+request.POST["time"],"%Y-%m-%d %H:%M")
dt =pytz.timezone("America/Toronto").localize(dt)
|
Printing the value of dt after that call, it looks correct.
Later on, I pull that booking out of my database by ID and render it
in my template, rendering the datetime like this:
|
<small>{{booking.date_time}}</small>
|
I've tried re-interpreting the timezone after pulling it out of the
database, to no avail. When I print the datetime object directly
after it is pulled out of MySQL, I get it in UTC like so:
|
2014-08-3016:00:00+00:00
|
Re-interpreting it to force it into the office's local timezone, I
get the correct result but 1 hour off is still rendered in the web
browser
|
# returns 2014-08-30 12:00:00-04:00
booking.date_time
=pytz.timezone("America/Toronto").normalize(booking.date_time)
|
The result of this is the time is rendered /1 hour behind/ the actual
time. This is consistent across all datetimes I've tried, and I seem
to be unable to get Django to render the correct time.
My question is this: Why is my datetime consistently rendering 1 hour
off, and how do I wrangle it into rendering at the true time?
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to django-users+unsubscr...@googlegroups.com
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto:django-users@googlegroups.com>.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/2dbd562a-5db3-4787-80d2-5a0f93f07860%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/2dbd562a-5db3-4787-80d2-5a0f93f07860%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto:django-users@googlegroups.com>.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/1408537967.3259961.154775081.30E70C64%40webmail.messagingengine.com
<https://groups.google.com/d/msgid/django-users/1408537967.3259961.154775081.30E70C64%40webmail.messagingengine.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/BLU436-SMTP1622B2A3A78EBAA5CF38D34E2D20%40phx.gbl.
For more options, visit https://groups.google.com/d/optout.