date-format-lib

1.0.1 • Public • Published

Date-lib

Help javascript users to get the formatted date string from the date

Build Status Coverage Status Codacy Badge License: MIT

Installing

npm install --save date-format-lib

Usage

When you use ES5

var DateLib = require('date-format-lib');

When you use ES6

import DateLib form 'date-format-lib';

Get today's date string with a giving pattern Assume today is March 16 1982

console.log(DateLib.getCurrentDateString('yyyy/mm/dd'));
// Output 1982/03/16
console.log(DateLib.getCurrentDateString('yyyy-mm-dd'));
// Output 1982-03-16
console.log(DateLib.getCurrentDateString('mm-dd-yyyy'));
// Output 03-16-1982
console.log(DateLib.getCurrentDateString('dd-mm-yyyy'));
// Output 16-03-1982
console.log(DateLib.getCurrentDateString('mm*dd&yyyy'));
// Output 03*16&1982

Get a giving date's string with a giving pattern You can use either a string or a Date object for the date source.

console.log(DateLib.getDateString('03/16/1982', 'yyyy/mm/dd'));
// Output 1982/03/16
console.log(DateLib.getDateString('03/16/1982', 'yyyy-mm-dd'));
// Output 1982-03-16
console.log(DateLib.getDateString(new Date('03/16/1982'), 'yyyy-mm-dd'));
// Output 1982-03-16

License

Date-lib is licensed under MIT License - see the License file.

/date-format-lib/

    Package Sidebar

    Install

    npm i date-format-lib

    Weekly Downloads

    1

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    4.82 kB

    Total Files

    4

    Last publish

    Collaborators

    • kevinwang0316