https://github.com/blakek/date2timestamp
Convert a date to its corresponding UNIX timestamp
https://github.com/blakek/date2timestamp
Last synced: about 1 month ago
JSON representation
Convert a date to its corresponding UNIX timestamp
- Host: GitHub
- URL: https://github.com/blakek/date2timestamp
- Owner: blakek
- License: mit
- Created: 2016-01-26T20:10:12.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-12-01T15:40:08.000Z (over 8 years ago)
- Last Synced: 2025-11-12T11:27:04.211Z (9 months ago)
- Language: Shell
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# date2timestamp
> Convert a date to its UNIX epoch timestamp
I needed to convert dates to timestamps for time tracking and scheduling things to go live. This helps with that.
## Usage
Get timestamp for today at midnight (00:00):
```bash
date2timestamp
# Example output: 1478498400
```
Get timestamp for some other day (2020-08-26):
```bash
date2timestamp -y 2020 -m 8 -d 26
# Output: 1598418000
```
Get timestamp for really specific time (2020-08-26 at 03:55:12):
```bash
date2timestamp -y 2020 -m 8 -d 26 -H 3 -M 55 -S 12
# Output: 1598432112
```
**NOTE:**
Need to convert a timestamp back to a human-readable date? Run:
```bash
# Linux / GNU-based
date -d @1267619929
# macOS / BSD-based
date -r
```
## Install
### Option 1: use `yarn` or `npm`
If using [npm](https://www.npmjs.com/):
```shell
npm i -g date2timestamp
```
If using [Yarn](https://yarnpkg.com/):
```shell
yarn global add date2timestamp
```
### Option 2: manual installation
1. Either [clone this repository](https://help.github.com/articles/cloning-a-repository/) or [download the ZIP file](https://github.com/blakek/date2timestamp/archive/master.zip)
2. Add this to your $PATH
## License
[MIT](https://raw.githubusercontent.com/blakek/date2timestamp/master/LICENSE)