A simpler method:
from datetime import datetime
from pytz import timezone
south_africa = timezone('Africa/Johannesburg')
sa_time = datetime.now(south_africa)
print sa_time.strftime('%Y-%m-%d_%H-%M-%S')
More Related Contents:
- Does Python’s time.time() return the local or UTC timestamp?
- Python get current time in right timezone [duplicate]
- Python: Figure out local timezone
- Use Python to find out if a timezone currently in daylight savings time [duplicate]
- Find if 24 hrs have passed between datetimes
- How accurate is python’s time.sleep()?
- How to wait some time in pygame?
- How to make a timezone aware datetime object
- Getting computer’s UTC offset in Python
- How do I check the difference, in seconds, between two dates?
- Making a countdown timer with Python and Tkinter?
- time.sleep — sleeps thread or process?
- How do I get the current time in milliseconds in Python?
- How to run a function periodically in python
- Get Timezone from City in Python/Django
- How to remove timezone from a Timestamp column in a pandas dataframe
- Splitting timestamp column into separate date and time columns
- python – datetime with timezone to epoch
- Python speed testing – Time Difference – milliseconds
- How do I change the file creation date of a Windows file?
- Week number of the month?
- Difference between Python datetime vs time modules
- Python pytz timezone function returns a timezone that is off by 9 minutes
- In python, how to check if a date is valid?
- How can I parse free-text time intervals in Python, ranging from years to seconds?
- How to add hours to current time in python
- Python time to age, part 2: timezones [duplicate]
- Accurate timing of functions in python
- Python logging: use milliseconds in time format
- How do I print a datetime in the local timezone?