knockout.moment

2.0.1 • Public • Published

Knockout Moment Component

A simple knockout extender that wraps moment.js.

Installation

npm install knockout-moment

Then add knockout-moment.js to your project.

Usage

require the script in your bundle, then:

var myDate = ko.observable().extend({moment: true});
myDate("May 15, 2014");
 
console.log("YYYY-MM-DD-HH[h]mm[m]s[s]: " + myDate.linkable());
console.log("YYYY-MM-DD: " + myDate.nativeFormat());
console.log("MM/DD/YYYY: " + myDate.usFormat());
console.log("MMMM Do, YYYY: " + myDate.articleFormat());
console.log("h:mm a: " + myDate.localTime());
console.log("HH:mm: " + myDate.localTime24());
console.log("MMM: " + myDate.monthName());
console.log("DD: " + myDate.dayOfMonth());
console.log("ISO8601: " + myDate.iso8601());

This will coerce all values passed to the observable to type of moment and add the aforementioned computed values.

Readme

Keywords

none

Package Sidebar

Install

npm i knockout.moment

Weekly Downloads

1

Version

2.0.1

License

MIT

Last publish

Collaborators

  • chadly
  • mdarens
  • tullo_x86