Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bitty/format-date

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bitty/format-date

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

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
44
increased by57.14%
Maintainers
1
Weekly downloads
 
Created
Source

@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 less than 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 "minutes" using same syntax as moment.

Supported tokens

Right now this lib supports the tokens below.

TokenTypeRange
DDDay01 to 31
DDay1 to 31
MMMonth01 to 12
MMonth1 to 12
YYYYYear0000 to 9999
YYYear0 to 99
HHHour00 to 23
HHour0 to 23
mmMinute00 to 59
mMinute0 to 59
ssSecond00 to 59
sSecond0 to 59
[*]Escape 

License

Released under MIT License.

FAQs

Package last updated on 14 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc