🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

simple-datejs

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-datejs

for use in place of javascript date object which does not carry the time component

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

simple-date

This date object is for use in place of the default javascript date object. It does not have a time component, and adds some cool features like getting the days difference between two dates.

##install $ npm install simple-datejs

$ bower install simple-datejs

$ jspm install simple-datejs

##usage

constructors

var SimpleDate = require('simple-datejs');

//creates current date
var date = new SimpleDate();
//creates passed in date
date = new SimpleDate(2015, 6, 4);
//creates date from json object
date = new SimpleDate({year: 2015, month: 6, date: 4});
//create date from existing date or simple date
date = new SimpleDate(date);
//create date from a javascript date object
date = new SimpleDate(new Date());

get difference between two dates

var date = new SimpleDate();
var date2 = new SimpleDate();
date.addDays(5);

var diff = date.getDaysDifference(date2);

// -5
console.log(diff);

writing and parsing date string

var SimpleDate = require('simple-datejs');

var date = new SimpleDate();

console.log(date.toString()); //yyyy-MM-dd
console.log(date.toString('MM/dd/yyyy'); //ex: 07/27/2016
console.log(date.toString('MMMM dd, yyyy'); //ex: July 07, 2015

date = SimpleDate.parse('2015-07-27', 'yyyy-MM-dd');
date = SimpleDate.parse('07/27/2015', 'MM/dd/yyyy');

calculating dates on a given period between two dates

0 - one time
1 - daily
2 - weekly
3 - biweekly
4 - monthly

var SimpleDate = require('simple-datejs');

var frequency = 2;
var start = new Date(2014, 6, 25);
var end = new Date(2015, 6, 25);

//[date,date,date]
var dates = SimpleDate.calculatePeriodDates(start, end, frequency);

console.log(dates);

Keywords

date

FAQs

Package last updated on 28 Nov 2015

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