Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5637

Beginners • Re: Calling Standard Time Via Strftime

$
0
0
Thanks for that explanation.

I just tested out the following code to change a pi which was initialized as Phoenix, Arizona (i.e. -7 time zone), to a time zone of -5 (east coast United States time zone):

Code:

import osimport timeprint(time.strftime("%H:%M:%S"))os.environ["TZ"] = "UTC+5"time.tzset()print(time.strftime("%H:%M:%S"))
Prior to running the script the clock showed 9:45 am (which was the current local time in Phoenix, Arizona).

I ran that script and it outputted the following:

09:45:23
11:45:23

This appeared to work, however the clock time in the right hand corner of the pi, still showed 9:45. (I continued to watch it until it reached 9:50.)

I then tried re-running the script, and got the following output:

09:52:41
11:52:41

I assume if the change worked, both time outputs would report "11:52:41", as the time zone was already changed. Thus, it doesn't appear to me, that this is causing a system wide change of timezone. It only appear to change it temporarily.

Am I doing something incorrectly?

Statistics: Posted by mogo4414 — Sat Dec 28, 2024 5:05 pm



Viewing all articles
Browse latest Browse all 5637

Trending Articles


Practice Sheet of Right form of verbs for HSC Students


Sarah Samis, Emil Bove III


ZARIA CUMMINGS


Need radio code for IVECO Delphi Aptiv FJ5 RBT M16


Black Angus Grilled Artichokes


Ed Sheeran – Sapphire – Pre-Single [iTunes Plus M4A]


Sunny Garcia’s Ex-Wife Colleen McCullough


99 God Status for Whatsapp, Facebook


Funeral of Sir Warwick Franklin


MHDD