From eb9cc5daaa5a482c769805a2a1b0df4b9f8b2809 Mon Sep 17 00:00:00 2001 From: Paul Li Date: Sun, 3 Nov 2024 14:08:52 -0700 Subject: [PATCH] update time format --- wastewater_qpcr_app/wastewater_qpcr_app.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wastewater_qpcr_app/wastewater_qpcr_app.py b/wastewater_qpcr_app/wastewater_qpcr_app.py index d835cc4..69163f4 100755 --- a/wastewater_qpcr_app/wastewater_qpcr_app.py +++ b/wastewater_qpcr_app/wastewater_qpcr_app.py @@ -281,9 +281,11 @@ def init_page(pathogen): latest_time = ti if latest_time: - t_obj = time.localtime(latest_time) - os.environ["TZ"] = "MT" - time_stamp = time.strftime("%Y-%m-%d %H:%M:%S MT", t_obj) + import pytz + from datetime import timezone, datetime, timedelta + utc_dt = datetime.fromtimestamp(ti, tz=timezone.utc) + mt_timezone = pytz.timezone('America/Denver') + time_stamp = utc_dt.astimezone(mt_timezone).strftime('%Y-%m-%d %H:%M:%S MT') else: time_stamp = "Unknown"