Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

@djforth/date-formatter

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@djforth/date-formatter

Date Formatter

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

Dateformatter

Utility For processing and formatting dates in javascript

Install

Install via NPM


npm install dateformatter

or via bower


bower install dateformatter

Setup

To parse a date string

  // yyyy-mm-dd hh:mm:ss
  // yyyy-mm-dd hh:mm
  // yyyy-mm-dd
  var datefmt = new DateFormatter("2015-01-28 16:44");

  //or as standard date str
  var datefmt = new DateFormatter("2015/01/28 16:44");

  //or as standard
  var datefmt = new DateFormatter(2015, 0, 28, 16,44);

  //or pass a date object
  var date = new Date(2015, 0, 28, 16,44)
  var datefmt = new DateFormatter(date);

Methods

Format Date

This is based on ruby's strftime and allows you to convert a date object into formatted string as required.

Options:

  • %y - Year (e.g. 15)
  • %Y - Full Year (e.g 2015)
  • %m - Month (e.g 1)
  • %b - Short Text month (e.g Jan)
  • %B - Full month (e.g January)
  • %d - Date (e.g 28)
  • %a - Short Day (e.g. Sun)
  • %A - Day (e.g. Sunday)
  • %H - 24 Hours with 0 (e.g. 08)
  • %h - 24 hour without 0 (e.g. 8)
  • %-l - 12 hour (e.g. 8 or after 12 like 16:00 would be 4)
  • %p - AM or PM
  • %M - Mins with 0 (e.g. 09)
  • %-M - Mins without 0 (e.g. 9)
  • %S - seconds with 0 (e.g. 09)
  • %s - seconds without 0 (e.g. 9)

So you can call something like this:

  var fmt = dateFmt.formatDate("%A, %d %B %Y at %-l:%M%p.")
  console.log(fmt) // Sunday, 18 January 2015 at 4:44pm.

Bug reports

If you discover any bugs, feel free to create an issue on GitHub. Please add as much information as possible to help us fixing the possible bug. We also encourage you to help even more by forking and sending us a pull request.

https://github.com/djforth/urlparser/issues

Contribute

If you'd like to contribute, URLParser is written using babel in ES6.

Please make sure any additional code should be covered in tests (Jasmine using karma).

If you need to run the test please use:


gulp app:watch

or to rebuild the JS run:


gulp build

Maintainers

Adrian Stainforth (https://github.com/djforth)

License

URLParser is an open source project falling under the MIT License. By using, distributing, or contributing to this project, you accept and agree that all code within the URLParser project are licensed under MIT license.

Keywords

Date

FAQs

Package last updated on 26 Jan 2016

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