I’m slowly improving my Python skills, mostly by Googling and combining multiple answers to code a solution to my systems administration tasks. Today I decided to write a simpe converter that takes Epoch Time as a parameter and returns you the time and date it corresponds to.
datetime and timezone Modules in Python
Most of the functionality is done using the fromtimestamp function of the datetime module. But because I also like seeing time in UTC, I decided to use timezone module as well.
FIXME: I’ll revisit this to re-publish script directly from GitHub.
Here’s how you can use the script:
I implemented basic checks:
script won’t run if no command line parameters are passed
an error message will be shown if command line parameter isn’t a number (and therefore can’t be a timestamp)
Do you see anything that should be changed or can be improved? Let me know!