That's exactly right, but what's rendered in the browser is 11 AM rather 
than 12:00

On Wednesday, 20 August 2014 08:36:58 UTC-4, Geoffrey Knauth wrote:
>
> 2014-08-30 16:00:00+00:00 GMT
> 2014-08-30 12:00:00-04:00 Toronto (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...@googlegroups.com <javascript:>.
>  To post to this group, send email to django...@googlegroups.com 
> <javascript:>.
>  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.
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/dc50a5e0-fa60-4681-89ca-5a8f3288b732%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to