@socotra/tz
v2.3.0
Published
Timezone utility
Downloads
13
Maintainers
Keywords
Readme
Socotra Timezone Utility
A utility for converting to and from Unix timestamps and between various timezones.
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
- Supported date/time formats Moment on NPM
- Supported time zones Moment Timezone on NPM