I often need to use Unix timestamps to search for stuff in MySQL tables. So I wrote this tool to quickly convert a date string to an Unix timestamp and vice versa.
Credits to the date-util library for providing the strtotime parser.
- Clone this repo
- Install dependencies:
npm install
- Run Webpack to generate a build:
npm run build
- (For Unix systems) add executable permissions:
chmod +x bin/index.js
- Make the CLI tool globally available on your system:
npm install -g .
After installation the tool should be available as the unixtime
command. There are two sub commands:
This is the default command. Use unixtime <string>
or unixtime to-unix <string>
to convert an English datestring to an Unix timestamp. Eg. unixtime to-unix "+30 days"
Use unixtime from-unix <timestamp>
to convert an Unix timestamp back to a normal datetime string.