0.2.0 • Published 10 years ago

date-stylish v0.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

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

OptionsTypeReturnOutput
nowdateStringDD/MM/YYYY - hh:mm:ss
inowdateStringYYYY/MM/DD - hh:mm:ss
YYYYdateStringfull year
MMdateStringmonth
DDdateStringdate
hhdateStringhours
mmdateStringminutes
ssdateStringseconds
setfuncnull sets internal time

Contribute

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

License

MIT License © Vitor Britto

0.2.0

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago