Skip to main content

Quick timezone and time format conversion CLI tool

Project description

timetool (t)

timetool, or t, is a little command line utility for you to convert between different timezones and datetime formats.

It accepts a time as input, in any format, and then outputs it in many different formats and timezones at once.

timetool is not meant to used in scripts, it was just created to be a better & faster alternative to commonly used web tools like https://www.epochconverter.com/ and https://www.timeanddate.com/worldclock/converter.html.

Install

pip install timetool

# Alias timetool as t. This is optional, but recommended for fast access.
alias t=timetool
echo 'alias t=timetool' >> ~/.bashrc
echo 'alias t=timetool' >> ~/.zshrc

Examples

Convert from a unix timestamp to many other formats:

$ t 2303078400
2303078400
2042-12-25T00:00:00.000+00:00     Dec 25, 2042 0:00:00 UTC
2042-12-24T16:00:00.000-08:00     Dec 24, 2042 4:00:00 PM PST
Dec 25, 2042 0:00 UTC (Dec 24 4:00p PST)

(Note: all the examples on this page were ran from a computer in California, hence the automatic inclusion of Pacfic Time ("PST" and "PDT") in all results)

Get the current time in many different timezones at once:

$ t now in ist,cst,cet
1640487650
2021-12-25T19:00:49.759-08:00     Dec 25, 2021 7:00:49 PM PST
2021-12-26T08:30:49.759+05:30     Dec 26, 2021 8:30:49 AM IST
2021-12-25T21:00:49.759-06:00     Dec 25, 2021 9:00:49 PM CST
2021-12-26T04:00:49.759+01:00     Dec 26, 2021 4:00:49 CET
2021-12-26T03:00:49.759+00:00     Dec 26, 2021 3:00:49 UTC
Dec 25, 2021 7:00:49 PM PST (Dec 26 8:30:49a IST / Dec 25 9:00:49p CST / Dec 26 4:00:49 CET / Dec 26 3:00:49 UTC)

Parse in a time string from an arbitrary timezone:

$ t October 10th 2023 1:30 am Australia/Sydney
1696861800
2023-10-10T01:30:00.000+11:00     Oct 10, 2023 1:30:00 AM AEDT
2023-10-09T07:30:00.000-07:00     Oct 09, 2023 7:30:00 AM PDT
2023-10-09T14:30:00.000+00:00     Oct 09, 2023 14:30:00 UTC
Oct 10, 2023 1:30 AM AEDT (Oct 09 7:30a PDT / Oct 09 14:30 UTC)

Display what time it was 7 hours ago:

$ t -7h
1640463095
2021-12-25T12:11:34.903-08:00     Dec 25, 2021 12:11:34 PM PST
2021-12-25T20:11:34.903+00:00     Dec 25, 2021 20:11:34 UTC
Dec 25, 2021 12:11:34 PM PST (20:11:34 UTC)

Usage

Usage: timetool [-h] [TIME] [in CONVERSION_TIMEZONE]

Examples:
  timetool
  timetool 1621108906
  timetool 1621108906000
  timetool 1621108906.000
  timetool May 15, 2021 01:01:46 PM PDT
  timetool 2021 May 15th 1:01 PM GMT-0700
  timetool 2021-05-15T20:01:46.000+00:00
  timetool 5pm PDT in CEST
  timetool now in Asia/Hong_Kong
  timetool now in IST,EDT,CEST,Asia/Tokyo
  timetool -7d
  timetool +1.5h
  timetool +1mo
  timetool +01:30:00

Help & support:
  https://github.com/personalcomputer/timetool/issues

Credit

All the smarts in timetool are thanks to dateutil, pytz, babel, the CLDR and the tz database.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

timetool-0.7.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

timetool-0.7-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file timetool-0.7.tar.gz.

File metadata

  • Download URL: timetool-0.7.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for timetool-0.7.tar.gz
Algorithm Hash digest
SHA256 5cc09b6d1e7c200564767fa2b11067165e7c1a8f16ec159c0395968615b4c4c5
MD5 013af0224b750328a158de34d77e875a
BLAKE2b-256 f8c4d9d5a64f2e2336698a45a672e26bb2d42e22ab4609c51e21da08b17f0355

See more details on using hashes here.

File details

Details for the file timetool-0.7-py3-none-any.whl.

File metadata

  • Download URL: timetool-0.7-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for timetool-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 34fa6bc3ccc00500538f312c3bb53b7f58ab5119bf8a2f4e763adf03acc65ff9
MD5 307d17d15a2c0b569ead6509b7b913f1
BLAKE2b-256 c41d07dd492a686cbcd9dc2aa861e4b82186270fa0dbd9c852b68f6e425a386b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page