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

dateable

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dateable

A date formatter and parser for node

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

dateable

A small library that provides a few very useful methods for displaying dates, including a formatter and a parser.

Install

$ npm install dateable

How?

var dateable = require('dateable');

var str = dateable.format(new Date(), 'MM/DD-YYYY, hh:mm'); // e.g., 03/23-2012, 22:10

dateable.parse(str, 'MM/DD-YYYY, hh:mm') // Returns the original date

If you want to include text in the formatting, just escape it with either ' or ".

var date = new Date(2009, 4, 23)
  , format = '"I went to the moon in" YYYY. "I think it was a" dddd "in" MMMM';

dateable.format(date, format); // I went to the moon in 2009. I think it was a Saturday in May

You can also get the answers to simple questions, such as:

var date = new Date(2008, 4, 20);

dateable.when(date); // 4 years ago

// The same question can be asked for future days
dateable.when(new Date(2020, 4, 30)); // in 8 years

// And...
dateable.diff(new Date(2015), new Date()); // 3 years

Why?

Because dealing with dates in javascript is a fucking pain in the ass!

Keywords

FAQs

Package last updated on 31 May 2012

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