You try to make this: 1. Add library in the front-end to get user timezone ( this code need to be in the first page that user access ), to get timezone first.
- https://bitbucket.org/pellepim/jstimezonedetect/src {{if timezone_is_unknown: }} <script> $(function() { var tz_name = jstz.determine(); $.get("{{=URL('default', 'define_timezone')}}", tz_name); }); </script> 2. Add the controller responsible by determine timezone: def define_timezone(): """Call ajax to determine user timezone""" tz_name = request.vars.name from pytz import all_timezones_set if tz_name in all_timezones_set: session.user_timezone = tz_name 3. And in the your model you put: from pytz import timezone timezone_user = session.user_timezone or timezone('UTC') timezone_is_unknown = session.user_timezone is None 4. Use in the your model related with timezone: IS_DATETIME(format=("%m-%d-%Y %H:%H), timezone = pytz.timezone(timezone_user) ) There are other form, that is insert everything in UTC datetime and create a function responsible to convert this timezone in UTC datetime inserted in database. Just delayed a lot of kkkk, but yet I will create a web2py_timezone_starter with app ready to receive apps that are handled by timezones. I'm creating this application to demonstrate this, if you want look.. http://marlysson.pythonanywhere.com/timezone At app, the *Hour "your PC"* is datetime.now() simulating datetime of user, just that it's datetime of the pythonanywhere. Em quinta-feira, 7 de julho de 2016 16:19:10 UTC-3, Jeff Riley escreveu: > > Hello all. Me again. I have run into an interesting issue. I have > installed and followed niphlod's w2p_timezone_plugin. In order to make it > work on my local PC I need to setup my db.py as follows. > > import pytz > user_timezone = session.plugin_timezone_tx or 'UTC' > > > db.define_table('events', > Field('event_time', 'datetime', default = request.now, update > = request.now, > requires=IS_DATETIME(format=('%m-%d-%Y %H:%M'), > timezone=pytz.timezone(user_timezone))), > > > But to get it to work on pythonanywhere.com I have to setup my db.py as > follows. Any ideas why? > > > import pytz > > db.define_table('events', > Field('event_time', 'datetime', default = request.now, update > = request.now, > requires=IS_DATETIME(format=('%m-%d-%Y %H:%M'), > timezone=pytz.timezone("US/Central"))), > > > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.