This package has been deprecated

Author message:

Package is not developed anymore.

moment-strftime2
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/moment-strftime2 package

1.0.2 • Public • Published

moment-strftime2

END OF DEVELOPMENT NOTICE - This package has been discontinued

strftime support for Moment.js

Introduction

Moment.js is a great, lightweight date-manipulation library, with a very approachable date format syntax that makes it a breeze to work with dates and times in the Javascript world.

Unfortunately, the library doesn't support (and won't do it) one of the most common approaches to format strings: the Unix-Style strftime syntax.

This plugin (any many others) aims to fill the gap.

Installation (NPM)

Simply do:

npm install moment-strftime2

Installation (Bower)

Simply do:

bower install moment-strftime2

Usage

const moment = require('moment')
require('moment-strftime2').installTo(moment)
 
moment().strftime('%m/%d/%y %I:%M %p %Z') // => "16/09/11 09:22 AM CET"

Supported modifiers

This plugin supports all modifiers listed here with the exception of the following:

  • %c
  • %C
  • %E
  • %G
  • %n
  • %O
  • %t
  • %U
  • %x
  • %X
  • %+

And with the addition of the following modifiers:

  • %L: The milliseconds as decimal-number (range 000 to 999).

Customization

You can completely customize moment-strftime2 behavior by requiring the module and overriding the separator and modifiers variables:

Example:

const moment = require('moment')
const strftime2 = require('moment-strftime2')
strftime2.installTo(moment)
 
moment('2016-10-10 12:34:56.135 +02:00').strftime('%d %o #d #o') // "10 %o #d #o"
strftime2.separator = '$'
strftime2.modifier.o = 'DD'
moment('2016-10-10 12:34:56.135 +02:00').strftime('%d %o #d #o') // "%d %o 10 10"

Supported implementations.

moment-strftime2 supports and has been tested on NodeJS 6.0+.

API Documentation

The API documentation can be found here.

Contributing to moment-strftime2

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.

Copyright

Copyright (C) 2016 and above Shogun mailto:shogun@cowtech.it.

Licensed under the MIT license, which can be found at https://choosealicense.com/licenses/mit.

Package Sidebar

Install

npm i moment-strftime2

Weekly Downloads

8

Version

1.0.2

License

MIT

Unpacked Size

6.93 kB

Total Files

5

Last publish

Collaborators

  • shogun_panda