date2timestamp

1.0.1 • Public • Published

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):

date2timestamp
# Example output: 1478498400

Get timestamp for some other day (2020-08-26):

date2timestamp -y 2020 -m 8 -d 26
# Output: 1598418000

Get timestamp for really specific time (2020-08-26 at 03:55:12):

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:

# Linux / GNU-based
date -d @1267619929

# macOS / BSD-based
date -r <timestamp>

Install

Option 1: use yarn or npm

If using npm:

npm i -g date2timestamp

If using Yarn:

yarn global add date2timestamp

Option 2: manual installation

  1. Either clone this repository or download the ZIP file
  2. Add this to your $PATH

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i date2timestamp

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • blakek