date-stylish

0.2.0 • Public • Published

Date Stylish NPM version GitHub version

NPM

Date and time with style.

Install

$ npm install --save-dev

Usage

var ds = require('date-stylish');

Example

var ds = require('date-stylish'),
    nw = ds.now,
    in = ds.inow,
    Y  = ds.YYYY,
    M  = ds.MM,
    D  = ds.DD,
    h  = ds.hh,
    m  = ds.mm;

// Get the current time
console.log('Current date: %s', nw);            // => Current time: 19/06/2014 - 15:50:25

// Get the current time (with inverse date)
console.log('Current date: %s', in);            // => Current time: 2014/06/19 - 15:50:25

// Get custom date/time
console.log('%s/%s/%s - %s:%s', Y,M,D,h,m);     // => 2014/06/19 - 15:50
console.log('%s/%s/%s - %s:%s', D,M,Y,h,m);     // => 19/06/2014 - 15:50
console.log('%s/%s/%s', Y,M,D);                 // => 2014/06/19
console.log('%s/%s/%s', D,M,Y);                 // => 19/06/2014

// Set published date (great for blog posts)
var pubDate = ds.now;
console.log('Published at: %s' + pubDate);      // => Published at: 19/06/2014 - 15:50:25

// Pretty up dates other than the current one:
var oldDate = new Date(0);
ds.set( oldDate );
console.log('Remember back when we started the clock?  I believe it was ' + ds.YYYY);

Options

Options Type Return Output
now date String DD/MM/YYYY - hh:mm:ss
inow date String YYYY/MM/DD - hh:mm:ss
YYYY date String full year
MM date String month
DD date String date
hh date String hours
mm date String minutes
ss date String seconds
set func _null _ sets internal time

Contribute

Feel free to contribute with this project or leave a suggestion.

License

MIT License © Vitor Britto

Readme

Keywords

Package Sidebar

Install

npm i date-stylish

Weekly Downloads

1

Version

0.2.0

License

MIT

Last publish

Collaborators

  • vitorbritto