util.timestamp
TypeScript icon, indicating that this package has built-in type declarations

0.0.44 • Public • Published

util.timestamp

Generates a string timestamp

build analysis code style: prettier testing NPM

This module is a thin wrapper on the strftime module to create a simple string timestamp with a consistent format. It uses the format rule:

%Y%m%d%H%M%S%L

This results in a 17 byte string representing the current timestamp. e.g.

20170126075705148

Installation

This module uses yarn to manage dependencies and run scripts for development.

To install as a global package:

$ yarn global add util.timestamp

To install as a development dependency with cli:

$ yarn add --dev util.timestamp

To build the app and run all tests:

$ yarn run all

Usage

There are two ways to use this package:

  • Command line
  • Function call

Command line

The timestamp can be generated from the command line using:

timestamp

This will return the default format above. This could be used in scripting.

Function call

The default JavaScript call will just return the timestamp format above as a string:

const timestamp = require('util.timestamp');
console.log(timestamp());

The function also has an option to set a format that is acceptable to the strftime library:

const timestamp = require('util.timestamp');
console.log(timestamp({
    dateFormat: '%B %d, %Y %H:%M:%S'
}));

// returns the string: 'April 28, 2011 18:21:08'

Readme

Keywords

none

Package Sidebar

Install

npm i util.timestamp

Weekly Downloads

4

Version

0.0.44

License

MIT

Unpacked Size

6.63 kB

Total Files

8

Last publish

Collaborators

  • jmquigley