Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

new-date

segmentio3mSEE LICENSE IN LICENSE1.0.3TypeScript support: definitely-typed

Creates a new Date, but accepts a few more input types than normal.

new, date, new-date

readme

new-date

CircleCI Codecov

Create a new Date, accepting more input types than normal, like Unix timestamps.

Installation

$ npm install new-date

API

newDate(Date|String|Number)

Returns a new Date object created from the input. The input can be:

  • Date objects
  • date strings
  • millisecond numbers
  • second numbers
  • millisecond strings
  • second strings
var newDate = require('new-date');

newDate(new Date);
newDate('Wed, 09 Aug 1995 00:00:00 GMT');
newDate('Aug 9, 1995');
newDate('2011-10-10T14:48:00');
newDate(1363288923637);
newDate(1363288923);
newDate('1363288923637');
newDate('1363288923');

changelog

1.0.1 / 2016-09-12

  • Consolidate analytics.js dependencies (#2)
  • Karma: Only pick up *.test.js files
  • Pass GREP through to Karma tests
  • Improve the way Karma configs get mixed together
  • Rename test files to include .test in name
  • Fix CI badge
  • Test against node, fix linting errors, remove Sauce concurrency limits
  • Update eslint-config
  • Fix installation instructions

1.0.0 / 2016-05-11

  • Modernize test harness
  • Formatting and fix linting errors, general cleanup
  • Remove component support

0.3.1 - July 8, 2014

  • loosen dep on isodate

0.3.0 - October 24, 2013

  • fix date object should return same date instance

0.2.0 - September 3, 2013

  • fix ISO date parsing in old browsers

0.1.2 - September 2, 2013

  • fix bug in package.json

0.1.1 - August 29, 2013

  • fix for firefox flooring dates

0.1.0 - July 24, 2013

  • package for NPM

0.0.2 - May 11, 2013

  • accept second and millisecond strings

0.0.1 - April 14, 2013

:sparkles: