Date and time in Python 2

Hello,

In Python 2, we can use print datetime.now() to know the date and the hour. But I believe this command indicate the English’s hour. I’m not English so I will like to know my country’s hour. Is it possible with a command?
Thank you in advance (and sorry if my english isn’t perfect) :slight_smile:

There are options for setting an offset as part of the datetime module- 8.1. datetime — Basic date and time types — Python 2.7.18 documentation If you’re looking for more automation you’d want to browse that module documentation and consider a web search since it’s easy for this to go wrong (there should be a few guides online but double check it’s python2 compatible).

I’ve seen tzlocal pop up sometimes tzlocal · PyPI when used for systems where getting the local time was a pain but there are other options out there like pytz though I’ve not used it before.

1 Like

Thank you very much :upside_down_face: