Socket
Socket
Sign inDemoInstall

good-date

Package Overview
Dependencies
0
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    good-date

A Javascript date class that makes sense


Version published
Weekly downloads
20
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Good Date

A Javascript date class that actually makes sense

let DateTime = require('good-date')

// a valid date with no time
let aDate = new DateTime('12/31/1999')
let aDate = new DateTime('1999-12-31')
let aDate = new DateTime('1999-12-31T00:00:00')

aDate.day       // 31
aDate.month     // 12
aDate.year      // 1999
aDate.date      // 12/31/1999

// easy time set/get
aDate.time = '1:30pm'
aDate.time = '1:30:20pm'
aDate.time = '1:30:20.5'
aDate.time = '1:30:20.5am'
aDate.seconds // 20.5
aDate.minute  // 30
aDate.amPm    // pm
aDate.hour12  // 1
aDate.hour24  // 13

// helpers
aDate.monthName // December
aDate.dayName   // Friday
aDate.weekIndex // 5
aDate.unix      // milliseconds since the unix epoch

// an invalid date throw errors instead of failing silently
let aDate = new DateTime('Blah')

FAQs

Last updated on 13 Jan 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc