user2740614
user2740614

Reputation: 283

Python converting time zone into hours?

I'm running some Django unit tests, and one of them involves creating timezone-aware datetimes.

My time stamp starts out as the string: 2011-12-05 00:00:00-07:00, which gets passed to the model constructor.

When I print the string stored in the model, I get: 2011-12-05 07:00:00+00:00. Why is the timezone offset being stored as the hour?

Upvotes: 0

Views: 48

Answers (1)

rafalmp
rafalmp

Reputation: 4068

From the documentation:

When support for time zones is enabled, Django stores datetime information in UTC in the database, uses time-zone-aware datetime objects internally, and translates them to the end user’s time zone in templates and forms

so it's not timezone converted to hours, but datetime converted to UTC timezone.

Upvotes: 2

Related Questions