All Projects → jonschlinkert → Time Stamp

jonschlinkert / Time Stamp

Licence: mit
Get a formatted timestamp. Used in gulp, assemble, generate, and many others.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Time Stamp

Tinydate
A tiny (349B) reusable date formatter. Extremely fast!
Stars: ✭ 990 (+851.92%)
Mutual labels:  time, date, datetime, timestamp, format
lit-date
Light-weight, faster datetime formatter for modern browsers.
Stars: ✭ 33 (-68.27%)
Mutual labels:  time, datetime, date, format
format-date
📆 A small library (around 400 B when gziped & minified) to format JavaScript `Date` object using same tokens as moment.
Stars: ✭ 25 (-75.96%)
Mutual labels:  datetime, date, format, timestamp
Gostradamus
Gostradamus: Better DateTimes for Go 🕰️
Stars: ✭ 148 (+42.31%)
Mutual labels:  time, date, datetime, format
date-php
这是一个Javascript模仿PHP日期时间格式化函数,使用方法和PHP非常类似,有丰富的模板字符,并在原来的基础上增加了一些模板字符。 This is a date function that implement PHP in Javascript. It is very similar to PHP, has rich template characters, and enhances some template characters on the basis of the original.
Stars: ✭ 24 (-76.92%)
Mutual labels:  time, datetime, date, format
Angular Moment Picker
Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js.
Stars: ✭ 536 (+415.38%)
Mutual labels:  time, date, datetime
Dateparse
GoLang Parse many date strings without knowing format in advance.
Stars: ✭ 1,365 (+1212.5%)
Mutual labels:  time, date, datetime
When
A natural language date/time parser with pluggable rules
Stars: ✭ 1,113 (+970.19%)
Mutual labels:  time, date, datetime
Laydate
layDate(日期与时间组件) 是 layui 独立维护的三大组件之一
Stars: ✭ 1,066 (+925%)
Mutual labels:  time, date, datetime
React Datetime Picker
A datetime picker for your React app.
Stars: ✭ 294 (+182.69%)
Mutual labels:  time, date, datetime
Carbon
A simple, semantic and developer-friendly golang package for datetime
Stars: ✭ 565 (+443.27%)
Mutual labels:  time, date, datetime
Zulu
A drop-in replacement for native Python datetimes that embraces UTC.
Stars: ✭ 52 (-50%)
Mutual labels:  time, date, datetime
Pendulum
Python datetimes made easy
Stars: ✭ 4,639 (+4360.58%)
Mutual labels:  time, date, datetime
Graphql Java Datetime
GraphQL ISO Date is a set of RFC 3339 compliant date/time scalar types to be used with graphql-java.
Stars: ✭ 89 (-14.42%)
Mutual labels:  time, date, datetime
Timestamp
⏰ A better macOS menu bar clock.
Stars: ✭ 296 (+184.62%)
Mutual labels:  time, date, timestamp
Period
PHP's time range API
Stars: ✭ 616 (+492.31%)
Mutual labels:  time, date, datetime
Carbon
A simple PHP API extension for DateTime
Stars: ✭ 75 (-27.88%)
Mutual labels:  time, date, datetime
Iso8601
Ruby parser to work with ISO8601 dateTimes and durations — http://en.wikipedia.org/wiki/ISO_8601
Stars: ✭ 70 (-32.69%)
Mutual labels:  time, date, datetime
Date And Time
A Minimalist DateTime utility for Node.js and the browser
Stars: ✭ 99 (-4.81%)
Mutual labels:  time, date, format
dayjs
Extended fork of Day.js - 2KB immutable date library alternative to Moment.js
Stars: ✭ 36 (-65.38%)
Mutual labels:  time, datetime, date

time-stamp NPM version NPM monthly downloads NPM total downloads Linux Build Status

Get a formatted timestamp.

Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your ❤️ and support.

(TOC generated by verb using markdown-toc)

Install

Install with npm:

$ npm install --save time-stamp

Usage

const timestamp = require('time-stamp');

console.log(timestamp());
//=> 2018-10-26

console.log(timestamp.utc());
//=> 2018-10-26

Customizing the timestamp

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

console.log(timestamp('YYYYMMDD'));
//=> 20181026

console.log(timestamp.utc('YYYYMMDD'));
//=> 20181026

Supported patterns

  • YYYY: full year (ex: 2018)
  • 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'));
//=> 20181026
console.log(timestamp.utc('YYYYMMDD'));
//=> 20181026

console.log(timestamp('YYYYMMDD:ss'));
//=> 20181026:24
console.log(timestamp.utc('YYYYMMDD:ss'));
//=> 20181026:24

console.log(timestamp('YYYY/MM/DD:mm:ss'));
//=> 2018/10/26:46:24
console.log(timestamp.utc('YYYY/MM/DD:mm:ss'));
//=> 2018/10/26:46:24

console.log(timestamp('YYYY:MM:DD'));
//=> 2018:10:26
console.log(timestamp.utc('YYYY:MM:DD'));
//=> 2018:10:26

console.log(timestamp('[YYYY:MM:DD]'));
//=> [2018:10:26]
console.log(timestamp.utc('[YYYY:MM:DD]'));
//=> [2018:10:26]

console.log(timestamp('YYYY/MM/DD'));
//=> 2018/10/26
console.log(timestamp.utc('YYYY/MM/DD'));
//=> 2018/10/26

console.log(timestamp('YYYY:MM'));
//=> 2018:10
console.log(timestamp.utc('YYYY:MM'));
//=> 2018:10

console.log(timestamp('YYYY'));
//=> 2018
console.log(timestamp.utc('YYYY'));
//=> 2018

console.log(timestamp('MM'));
//=> 10
console.log(timestamp.utc('MM'));
//=> 10

console.log(timestamp('DD'));
//=> 26
console.log(timestamp.utc('DD'));
//=> 26

console.log(timestamp('HH'));
//=> 00
console.log(timestamp.utc('HH'));
//=> 04

console.log(timestamp('mm'));
//=> 46
console.log(timestamp.utc('mm'));
//=> 46

console.log(timestamp('ss'));
//=> 24
console.log(timestamp.utc('ss'));
//=> 24

console.log(timestamp('ms'));
//=> 186
console.log(timestamp.utc('ms'));
//=> 186

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.

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Running Tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test
Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Related projects

You might also be interested in these projects:

Contributors

Commits Contributor
31 jonschlinkert
7 doowb
1 evocateur
1 mendenhallmagic
1 mvanroon
1 leesei
1 sleagon

Author

Jon Schlinkert

License

Copyright © 2018, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.8.0, on October 26, 2018.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].