multiclock.py 804 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/local/bin/python3
  2. #
  3. # this script will show time and date in different locations
  4. # Author: Anton TETERIN
  5. # web: https://2dz.fi
  6. #
  7. # list of zones:
  8. # >>> from pytz import country_names, country_timezones
  9. # >>> all_timezones = [country_timezones.get(country) for country in country_names]
  10. # >>> all_timezones
  11. #
  12. # 2024-04-28 * init /A
  13. # 2024-05-22 + doc to list timezones /A
  14. from datetime import datetime
  15. import pytz
  16. ts_utc = pytz.utc
  17. zones = [
  18. "UTC",
  19. "Europe/Dublin",
  20. "Europe/Madrid",
  21. "Europe/Paris",
  22. "Europe/Helsinki",
  23. "Europe/Moscow",
  24. "Asia/Riyadh",
  25. "Asia/Dubai",
  26. "Asia/Ho_Chi_Minh",
  27. "Asia/Bangkok",
  28. "Asia/Sakhalin",
  29. ]
  30. for zone in zones:
  31. ts = pytz.timezone(zone)
  32. print ( " ", datetime.now(ts).strftime("%Y-%m-%d %H:%M:%S"), " in ", ts )