Raspberry PI Set Time Zone

After setting the time zone from the terminal, the Raspberry PI will report the correct time given an Internet connection.

sudo dpkg-reconfigure tzdata

The following code can read and print the hours, minutes, and seconds.

import datetime

hours = datetime.datetime.now().strftime('%H')
minutes = datetime.datetime.now().strftime('%M')
seconds = datetime.datetime.now().strftime('%S')
print 'hours='+hours+' minutes='+minutes+' seconds='+seconds