Hello there,

I've been struggling with this issue for the last few days and I cannot seem to 
find the way to fix it. I've this web page with a form where a user is 
requested to enter a date and a time of the day. Then there is a search button 
which does a JSON post back to the server with certain information. The user 
selected date/time is sent also back to the server as part of this information. 
Right now, before sending data back to the server the selected date/time is 
converted to a timestamp, which is assumed to be in the client's time zone.

The server code attempts to convert this timestamp back to a valid datetime 
object, by means of:

datetime.datetime.fromtimestamp(int(self.request_data.get(TIME_OF_PICKUP_FIELD)))

but the function fromtimestamp is also applying the timezone conversation to 
the provide value which turns the datetime one hour ahead/behind the user's 
selected value. What's strange to me is that if I run this code outside 
Django's shell:

>>>datetime.datetime.fromtimestamp(1395160800)

the result is: datetime.datetime(2014,3,18,12,40)

which is correct since (client's timezone is America/Chicago and server's is 
America/Havana).

But if I try the same code with python manage.py shell:

>>>datetime.datetime.fromtimestamp(1395160800)

the result is: datetime.datetime(2014, 3, 18, 11, 40)

I've tried with USE_TZ=False (TIME_ZONE setting is America/Chicago and server 
local time is America/Havana) and I still get the same result. I guess a work 
around this issue would be to send the timestamp in UTC but I haven't found a 
reliable way to do so in Javascript.

I would appreciate any help.

Bests,

Yoanis.

-- 
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/0F5D31CD-462E-485D-9C2A-3613BD593C7C%402burbujas.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to