Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

date-components

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-components

Extract individual date components from a Date String

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

date-components Build Status

Extract individual date components from a Date String.

Install

$ npm install --save date-components

Usage

const dateComponents = require('date-components');

const dateString = 'Mon Feb 13 2017 13:37:38:09 GMT+0000 (WET)';
const components = dateComponents(dateString);

Running console.log(components) from the above code sample would result in:

{
  day: 13,
  weekday: 1,
  month: 1,
  year: 2017,
  hour: 13,
  minutes: 37,
  seconds: 38,
  milliseconds: 9,
  epoch: 1486993058009,
  dateString: 'Mon Feb 13 2017 13:37:38:09 GMT+0000 (WET)'
}

API

dateComponents(input)

input

Type: string

Returns an object with the following keys:

KeyDescription
dayThe day of the month (from 1-31)
weekdayThe day of the week (from 0-6)
monthThe month (from 0-11)
yearThe full year
hourThe hour (from 0-23)
minutesThe minutes (from 0-59)
secondsThe seconds (from 0-59)
millisecondsThe milliseconds (from 0-999)
epochReturns the number of milliseconds since midnight Jan 1 1970, and a specified date
dateStringThe original dateString value you passed to the function

License

MIT © Michael Wuergler

Keywords

FAQs

Package last updated on 13 Feb 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc