All Projects → VitorLuizC → format-date

VitorLuizC / format-date

Licence: MIT license
📆 A small library (around 400 B when gziped & minified) to format JavaScript `Date` object using same tokens as moment.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to format-date

dayjs
Extended fork of Day.js - 2KB immutable date library alternative to Moment.js
Stars: ✭ 36 (+44%)
Mutual labels:  datetime, date, moment, date-formatting
lit-date
Light-weight, faster datetime formatter for modern browsers.
Stars: ✭ 33 (+32%)
Mutual labels:  formatter, datetime, date, 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 (-4%)
Mutual labels:  datetime, date, format, date-format
Dayjs
⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API
Stars: ✭ 37,373 (+149392%)
Mutual labels:  datetime, date, moment, date-formatting
Tinydate
A tiny (349B) reusable date formatter. Extremely fast!
Stars: ✭ 990 (+3860%)
Mutual labels:  datetime, date, format, timestamp
imrc-datetime-picker
(Improved) React component datetime picker by momentjs 📆
Stars: ✭ 21 (-16%)
Mutual labels:  datetime, date, moment, momentjs
moment-cache
⏱ Simple utility to cache moment.js results and speed up moment calls.
Stars: ✭ 29 (+16%)
Mutual labels:  datetime, date, moment, moment-js
Time Stamp
Get a formatted timestamp. Used in gulp, assemble, generate, and many others.
Stars: ✭ 104 (+316%)
Mutual labels:  datetime, date, format, timestamp
Date Io
Abstraction over common javascript date management libraries
Stars: ✭ 382 (+1428%)
Mutual labels:  datetime, date, moment
ember-dayjs-helpers
Ember Template helpers based on day.js
Stars: ✭ 19 (-24%)
Mutual labels:  datetime, date, format
Angular Moment Picker
Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js.
Stars: ✭ 536 (+2044%)
Mutual labels:  datetime, date, moment
chronos
One library to rule the time
Stars: ✭ 17 (-32%)
Mutual labels:  datetime, date, moment
Rc Datetime Picker
React component for datetime picker by Moment.js
Stars: ✭ 85 (+240%)
Mutual labels:  datetime, date, moment
vscode-insertdatestring
An extension for Visual Studio Code that provides a configurable command for inserting the current date and time
Stars: ✭ 58 (+132%)
Mutual labels:  datetime, timestamp, date-formatting
discord-clock
A simple clock script for your bot to show what time it is in your server | Discord.js v13 ready!
Stars: ✭ 29 (+16%)
Mutual labels:  moment, momentjs, moment-js
Time
Building a better date/time library for Swift
Stars: ✭ 1,983 (+7832%)
Mutual labels:  datetime, date, date-formatting
Jest Date Mock
🌗 Mock `Date` when run unit test cases with jest. Make tests of Date easier.
Stars: ✭ 224 (+796%)
Mutual labels:  datetime, date, timestamp
Translatedjs
Internationalization and localization for JavaScript and Node.js
Stars: ✭ 17 (-32%)
Mutual labels:  formatter, date, format
Gostradamus
Gostradamus: Better DateTimes for Go 🕰️
Stars: ✭ 148 (+492%)
Mutual labels:  datetime, date, format
vue-translated
Internationalization (i18n) and localization (l10n) library for Vue.js v2.
Stars: ✭ 19 (-24%)
Mutual labels:  formatter, date, format

@bitty/format-date

Bundle minified size Bundle minified and gzipped size

@bitty/format-date is a small library (around 400 B when gziped & minified) to format JavaScript Date object using same tokens as moment.

  • 📦 Distributions in ESM, CommonJS, UMD and UMD minified formats.

  • Lightweight:

    • Weighs around 0.4KB (min + gzip).
  • 🔋 Bateries included:

    • No dependencies.
    • Its not based on newer browser's APIs or es2015+ features.
  • 🏷 Safe:

    • JSDocs and type declarations for IDEs and editor's autocomplete/intellisense.
    • Made with TypeScript as strict as possible.
    • Unit tests with AVA.

Installation

This library is published in the NPM registry and can be installed using any compatible package manager.

npm install @bitty/format-date --save

# For Yarn, use the command below.
yarn add @bitty/format-date

Installation from CDN

This module has a UMD bundle available through JSDelivr and Unpkg CDNs.

<!-- For UNPKG use the code below. -->
<script src="https://unpkg.com/@bitty/format-date"></script>

<!-- For JSDelivr use the code below. -->
<script src="https://cdn.jsdelivr.net/npm/@bitty/format-date"></script>

<script>
  // UMD module is exposed through the "isNullish" global function.
  console.log(formatDate);
  //=> "[Function: formatDate]"

  console.log(formatDate(new Date(), 'YYYY-MM-DD'));
  //=> "2020-06-14"
</script>

Usage

@bitty/format-date exports a function to format JavaScript Date object using moment tokens.

import formatDate from '@bitty/format-date';

formatDate(new Date(), 'DD/MM/YYYY HH [hours] [and] mm [minutes].');
// I'm escaping "hours", "and" and "minutes" using same syntax as Moment.js.

Tokens

Right now this lib supports the tokens below.

  Token Output
Year YY 70, 71, ... 19, 20.
YYYY 1970, 1971, ... 2019, 2020.
Month M 1, 2, ... 11, 12.
MM 01, 02, ... 11, 12.
Day of Month D 1, 2, ... 30, 31.
DD 01, 02, ... 30, 31.
Hour H 1, 2, ... , 22,23.
HH 01, 02, ... , 22,23.
Minute m 1, 2, ... , 58,59.
mm 01, 02, ... , 58,59.
Second s 1, 2, ... , 58,59.
ss 01, 02, ... , 58,59.
AM/PM A AM, PM.
a am, pm.
Escape [*]  

License

Released under MIT License.

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].