The datetime object does not have a tzinfo object. So please try this
import pytz from pytz import timezone query = GuestMessage.all().get() current = query.date user_tz = timezone('Asia/Singapore') current = current.replace(tzinfo=pytz.utc).astimezone(user_tz) self.response.write(current.strftime('%Y-%m-%d %H:%M:%S %z'))
To find the time zone from the request header:
county_code = self.request.headers['X-Appengine-Country']
If you get ImportError: No module named pytz , download the source here: pypi.python.org/pypi/gaepytz . Then move pytz dir to the root of your application engine project.
source share