Skip to content

Latest commit

 

History

History
115 lines (87 loc) · 2.79 KB

.verb.md

File metadata and controls

115 lines (87 loc) · 2.79 KB

Usage

const timestamp = require('{%= name %}');

console.log(timestamp());
//=> {%= timestamp() %}

console.log(timestamp.utc());
//=> {%= timestampUTC() %}

Customizing the timestamp

You may also pass a string to format the generated timestamp.

console.log(timestamp('YYYYMMDD'));
//=> {%= timestamp('YYYYMMDD') %}

console.log(timestamp.utc('YYYYMMDD'));
//=> {%= timestampUTC('YYYYMMDD') %}

Supported patterns

  • YYYY: full year (ex: {%= timestamp("YYYY") %})
  • MM: month (ex: 04)
  • DD: day (ex: 01)
  • HH: hours (ex: 12)
  • mm: minutes (ex: 59)
  • ss: seconds (ex: 09)
  • ms: milliseconds (ex: 532)

Usage Examples

console.log(timestamp('YYYYMMDD'));
//=> {%= timestamp('YYYYMMDD') %}
console.log(timestamp.utc('YYYYMMDD'));
//=> {%= timestampUTC('YYYYMMDD') %}

console.log(timestamp('YYYYMMDD:ss'));
//=> {%= timestamp('YYYYMMDD:ss') %}
console.log(timestamp.utc('YYYYMMDD:ss'));
//=> {%= timestampUTC('YYYYMMDD:ss') %}

console.log(timestamp('YYYY/MM/DD:mm:ss'));
//=> {%= timestamp('YYYY/MM/DD:mm:ss') %}
console.log(timestamp.utc('YYYY/MM/DD:mm:ss'));
//=> {%= timestampUTC('YYYY/MM/DD:mm:ss') %}

console.log(timestamp('YYYY:MM:DD'));
//=> {%= timestamp('YYYY:MM:DD') %}
console.log(timestamp.utc('YYYY:MM:DD'));
//=> {%= timestampUTC('YYYY:MM:DD') %}

console.log(timestamp('[YYYY:MM:DD]'));
//=> {%= timestamp('[YYYY:MM:DD]') %}
console.log(timestamp.utc('[YYYY:MM:DD]'));
//=> {%= timestampUTC('[YYYY:MM:DD]') %}

console.log(timestamp('YYYY/MM/DD'));
//=> {%= timestamp('YYYY/MM/DD') %}
console.log(timestamp.utc('YYYY/MM/DD'));
//=> {%= timestampUTC('YYYY/MM/DD') %}

console.log(timestamp('YYYY:MM'));
//=> {%= timestamp('YYYY:MM') %}
console.log(timestamp.utc('YYYY:MM'));
//=> {%= timestampUTC('YYYY:MM') %}

console.log(timestamp('YYYY'));
//=> {%= timestamp('YYYY') %}
console.log(timestamp.utc('YYYY'));
//=> {%= timestampUTC('YYYY') %}

console.log(timestamp('MM'));
//=> {%= timestamp('MM') %}
console.log(timestamp.utc('MM'));
//=> {%= timestampUTC('MM') %}

console.log(timestamp('DD'));
//=> {%= timestamp('DD') %}
console.log(timestamp.utc('DD'));
//=> {%= timestampUTC('DD') %}

console.log(timestamp('HH'));
//=> {%= timestamp('HH') %}
console.log(timestamp.utc('HH'));
//=> {%= timestampUTC('HH') %}

console.log(timestamp('mm'));
//=> {%= timestamp('mm') %}
console.log(timestamp.utc('mm'));
//=> {%= timestampUTC('mm') %}

console.log(timestamp('ss'));
//=> {%= timestamp('ss') %}
console.log(timestamp.utc('ss'));
//=> {%= timestampUTC('ss') %}

console.log(timestamp('ms'));
//=> {%= timestamp('ms') %}
console.log(timestamp.utc('ms'));
//=> {%= timestampUTC('ms') %}

Release history

v2.0.0

Breaking changes

Default pattern was changed from YYYY:MM:DD to YYYY-MM-DD. See issues/3 for more details.