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

dayjs-ext

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dayjs-ext

2KB immutable date time library alternative to Moment.js with the same modern API

  • 1.12.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.3K
decreased by-13.09%
Maintainers
1
Weekly downloads
 
Created
Source

Day.js Extended

Fast 2kB alternative to Moment.js with the same modern API

(This is an extended fork of the original project.)


Gzip Size NPM Version Build Status Codecov Dependency Status Dependency Status License

Day.js is a minimalist JavaScript library that parses, validates, manipulates, and displays dates and times for modern browsers with a largely Moment.js-compatible API. If you use Moment.js, you already know how to use Day.js.

dayjs().startOf('month').add(1, 'day').set('year', 2018).format('YYYY-MM-DD HH:mm:ss');
  • 🕒 Familiar Moment.js API & patterns
  • 💪 Immutable
  • 🔥 Chainable
  • 🌐 I18n support
  • 📦 2kb mini library
  • 👫 All browsers supported

Extensions to the original project

  • New plugin "customParseFormat" to parse input strings using custom formats.
  • New plugin "localizableFormat" to format dates according to the chosen locale.
  • New plugin "timeZone" to parse from and format to a date string using a time zone specified by its canonical name.
  • Corrected plugin "relativeTime" honouring grammar rules of the supported languages.
  • "UTC mode" for working in UTC, or for working with date-only values without the time part.
  • Additional locales (cs, sk, ua).
  • Check for dayjs instance by the instanceof operator.

Getting Started

Installation

npm install dayjs-ext --save

📚Installation Guide

API

It's easy to use Day.js APIs to parse, validate, manipulate, and display dates and times.

dayjs('2018-08-08') // parse

dayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // display

dayjs().set('month', 3).month() // get & set

dayjs().add(1, 'year') // manipulate

dayjs().isBefore(dayjs()) // query

📚API Reference

I18n

Day.js has great support for internationalization.

But none of them will be included in your build unless you use it.

import 'dayjs-ext/locale/es' // load on demand

dayjs.locale('es') // use Spanish locale globally

dayjs('2018-05-05').locale('zh-cn').format() // use Chinese Simplified locale in a specific instance

📚Internationalization

Plugin

A plugin is an independent module that can be added to Day.js to extend functionality or add new features.

import timeZone from 'dayjs-ext/plugin/timeZone' // load on demand

dayjs.extend(timeZone) // use plugin

dayjs().format('D.M.YYYY H:mm',
  { timeZone: 'Europe/Berlin' }) // convert to CET before formatting

📚Plugin List

Sponsors

See the sponsor list at the original project. Thank you for your support!

Contributors

See the contributor list at the original project. Thank you for your help!

License

Day.js is Extended licensed under a MIT License.

Keywords

FAQs

Package last updated on 14 Oct 2018

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