开发者社区> 镜像站> NPM> date2timestamp
date2timestamp
> Convert a date to its UNIX epoch timestamp
Last updated 3 years ago by blakek .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install date2timestamp 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.1                                ...           latest (3 years ago)

2 Versions

  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (0)
None