i have written a code which converts date and time into timezone , now the problem is i have tired to run the code in python console and in http function but in spite of having a same code i am getting different output of timestamp
in python console
from datetime import datetime
import time
qdate="08-03-2011 05:00:00"
ttimetuple=time.strptime(qdate,"%d-%m-%Y %H:%M:%S")
print time.mktime(ttimetuple)
output is 1299578400.0
in webservices or http function
def SaveDate(request,qdate):
qdate="08-03-2011 05:00:00" # i hard coded for a timing to verify the timestamp
ttimetuple=time.strptime(qdat开发者_JS百科e,"%d-%m-%Y %H:%M:%S")
data=time.mktime(ttimetuple)
return HttpResponse(data,mimetype='application/javascript')
output is 1299582000.0
I think this is because your console and web server are running under the different time zone settings.
Try
import time
print time.timezone
to check whether time zone of your console and the server is different.
精彩评论