@writetome51/get-date-time-id
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

getDateTimeID(options?): string

Returns current date and time as a string of digits.

// options:
{
    includeFullYear?: boolean, // default false
    ymdOrder?: 'ymd' | 'ydm' | 'myd' | 'mdy' | 'dym' | 'dmy', // default 'ymd'
    hmsOrder?: 'hms' | 'hsm' | 'msh' | 'mhs' | 'smh' | 'shm', // default 'hms'
    separator?: string, // default '-' 
    separateEach?: boolean, // default false
    includeTimezoneOffset: boolean, // default true
}

getDefaultsFor_getDateTimeIDOptions():
      Object

Returns default options for getDateTimeID().

Examples

getDateTimeID(); // Say date-time is May 22,2019, 2:22:10pm, in a time zone 2 hours ahead of GMT.
// --> '190522-142210+02'

getDateTimeID(); // Say date-time is May 22,2019, 2:22:10pm, in time zone 6 hours behind GMT.
// --> '190522-142210-06'

getDateTimeID({includeFullYear: true});
// --> '20190522-142210-06'

getDateTimeID({ymdOrder: 'mdy'});
// --> '052219-142210-06'

getDateTimeID({ymdOrder: 'mdy', separator: ''});
// --> '052219142210-06'

getDateTimeID({ymdOrder: 'mdy', separateEach: true});
// --> '05-22-19-14-22-10-06'

getDateTimeID({ymdOrder: 'mdy', hmsOrder: 'smh', 
    separateEach: true, includeTimezoneOffset: false}
);
// --> '05-22-19-10-22-14'

Installation

npm i @writetome51/get-date-time-id

Loading

// if using TypeScript:
import {getDateTimeID} from '@writetome51/get-date-time-id';
// if using ES5 JavaScript:
var getDateTimeID = require('@writetome51/get-date-time-id').getDateTimeID;

Package Sidebar

Install

npm i @writetome51/get-date-time-id

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

12.7 kB

Total Files

8

Last publish

Collaborators

  • writetome51