@socotra/tz
v2.5.0
Published
Timezone utility
Downloads
83
Keywords
Readme
Socotra Timezone Utility
A utility for converting to and from Unix timestamps and between various timezones.
Installation
npm install -g @socotra/tzUsage
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 informationExamples
Show the current date and time for the local timezone
tzShow the current date with the time set to midnight
tz -mShow the current date at midnight in ISO 8601 format for Australia/Sydney
tz -m -z Australia/Sydney --isoShow the current date at midnight in ISO 8601 format for America/Los_Angeles
tz -m -z America/Los_Angeles --isoShow the current date and time for the local timezone converted to America/Los_Angeles
tz -Z America/Los_AngelesConvert a timestamp to a human readable date
tz 1571103045123Convert a timestamp to a human readable date in the Australia/Sydney timezone
tz 1571103045123 -Z Australia/SydneyShow the timestamp for a date in ISO 8601 format
tz 2019-10-15T12:30:45.1234Show the timestamp for a date in DD/MM/YYYY format
tz -f DD/MM/YYYY 15/10/2019Show known timezones starting with "America"
tz --listzones AmericaUseful 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 ./tzlaAustralia/Sydney Timezone
alias tzau='tz -z Australia/Sydney'OR
echo tz -z Australia/Sydney "$@" > ./tzau
chmod +x ./tzauReferences
- Supported date/time formats Moment on NPM
- Supported time zones Moment Timezone on NPM
