Monday 15 September 2014

python - Can SQLAlchemy Date Time object display local time zone in Flask -


This is my first stackoverflow phrase, sorry my syntax.
I am trying to time-stamp in a timestamp without a date. Time zone in the SQLAlchemy database displays the time in the user's browser in their timezone over time, not UTC.

Here is my Python / flask code (I'm beginning):

First database query

  timeclockinfo = TimeClock.query .filter_by (parent_id = current_user.parent_id, user_id = current_user.user_id, off = 1) .all () # I tuple data child_patient = ZIP (timeclockinfo, user_names, visit_dates) # I flask return render_template ( 'locationcheckinrpt.html', Provide data with form = form, child_patient = child_patient, timeclockinfo = timeclockinfo, searchForm = searchForm). . . # Template I have records {% hair in%} {{time in [0] .checkintime.strftime ( '% Y /% m /% d @% I:% M% p' about UTC Times could give me any advice [0]. browser performance and UTC time to time in Upyogkrtaon.   I have a user's time zone, so I saved the appropriate numbers.  

However, I can not stop my way through displaying it.

If your Have Dettaim and user's time zone, you have to apply for an make Detl object, the required computing, and then print the string.

If your question is actually a time zone to take a look at a passive daytime object, then:

  Pitajh import tz = timezone ( 'saved_user_timezone') datetime import from dt = saved_time_from_db locl_dt = tz.localize (dt datetime timezone)  

Time zone offset To display date time with the field, try:

  local_dt.replace (hour = local_dt.hour + int (local_dt.utcoffset () Total_seconds () / 3600)) local_dt.strftime ( 'Your format')  

No comments:

Post a Comment