2.5.0 • Published 6 months ago

@socotra/tz v2.5.0

Weekly downloads
6
License
ISC
Repository
github
Last release
6 months ago

Socotra Timezone Utility

A utility for converting to and from Unix timestamps and between various timezones.

npm

Changelog

Installation

npm install -g @socotra/tz

Usage

Usage: tz [options] <value>

Options:
  -V, --version             output the version number
  -l, --listzones [prefix]  Lists known timezones, optionally starting with a prefix
  -z, --zonein <zone>       Sets the input timezone (default: "<timezone>")
  -Z, --zoneout <zone>      Sets the output timezone (default: "<timezone>")
  -m, --midnight            Overrides the time to midnight
  -f, --format <format>     A custom format string for value
  -s, --iso                 Output dates in ISO 8601 format
  -d, --debug               Output extra debugging info
  -h, --help                output usage information

Examples

Show the current date and time for the local timezone

tz

Show the current date with the time set to midnight

tz -m

Show the current date at midnight in ISO 8601 format for Australia/Sydney

tz -m -z Australia/Sydney --iso

Show the current date at midnight in ISO 8601 format for America/Los_Angeles

tz -m -z America/Los_Angeles --iso

Show the current date and time for the local timezone converted to America/Los_Angeles

tz -Z America/Los_Angeles

Convert a timestamp to a human readable date

tz 1571103045123

Convert a timestamp to a human readable date in the Australia/Sydney timezone

tz 1571103045123 -Z Australia/Sydney

Show the timestamp for a date in ISO 8601 format

tz 2019-10-15T12:30:45.1234

Show the timestamp for a date in DD/MM/YYYY format

tz -f DD/MM/YYYY 15/10/2019

Show known timezones starting with "America"

tz --listzones America

Useful aliases

You can create additional shell scripts as shown below:

America/Los_Angeles

alias tzla='tzla -z America/Los_Angeles'

OR

echo tz -z America/Los_Angeles "$@" > ./tzla
chmod +x ./tzla

Australia/Sydney Timezone

alias tzau='tz -z Australia/Sydney'

OR

echo tz -z Australia/Sydney "$@" > ./tzau
chmod +x ./tzau

References

2.5.0

6 months ago

2.4.0

6 months ago

2.3.0

2 years ago

2.2.0

2 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago