I'm having trouble getting it timezone.localize()working correctly. My goal is to capture today's date and convert it from CST to EST. Then finally format the date and time before spitting it out. I can format the date correctly, but the date-time does not change from CST to EST. Also, when I format the date, I do not see the textual representation of the included time zone.
Below I have listed a simple program that I created to test this:
import threading
import datetime
import pexpect
import pxssh
import threading
from pytz import timezone
import pytz
est = timezone('US/Eastern')
curtime = est.localize(datetime.datetime.now().strftime("%a %b %d %H:%M:%S %Z %Y"))
class ThreadClass(threading.Thread):
def run(self):
now = (datetime.datetime.now())
print "%s says Hello World at time: %s" % (self.getName(), curtime)
for i in range(3):
t = ThreadClass()
t.start()
source
share