dt-info

Get date and time info

Usage no npm install needed!

<script type="module">
  import dtInfo from 'https://cdn.skypack.dev/dt-info';
</script>

README

Date Time Info Build Status

Get date and time info

Install

$ npm i dt-info

Usage

// const dtInfo = require('dt-info')
const { DTInfo } = require('dt-info');
const dtInfo = new DTInfo();

Return data using promise.

Example

dtInfo.info(['day', 'minutes']).then(result => {
    console.log('result', result)
}).catch(error => {
    console.log('error', error)
})

Return data using callback.

Example

dtInfo.info(['day', 'minutes'], (error, result) => {
    console.log('result', result)
    console.log('error', error)
})

Return data without key with promise.

Example

dtInfo.info().then(result => {
    console.log('result', result)
}).catch(error => {
    console.log('error', error)
})

Return data without key with callback.

Example

dtInfo.info((error, result) => {
    console.log('result', result)
    console.log('error', error)
})

Output

{
    day: 0,
    date: 24,
    month: 6,
    fullYear: 2018,
    hours: 14,
    minutes: 23,
    seconds: 7,
    milliseconds: 510,
    week: 0,
    time: 1529829487510,
    timezoneOffset: -345,
    UTCFullYear: 2018,
    UTCMonth: 5,
    UTCDate: 24,
    UTCDay: 0,
    UTCHours: 8,
    UTCMinutes: 38,
    UTCSeconds: 7,
    UTCMilliseconds: 510
}
``

## API

### new DTInfo()

Returns a new instance.

### Instance

#### .info([key, Promise | Callback])

Returns a `Promise/Callback` for a result `Object` with a `Error`.

## License

MIT © [Joydip Roy (rjoydip)](https://github.com/rjoydip/dt-info/blob/master/license.md)