#simple-momentpicker ![Circle CI](https://circleci.com/gh/mycolorway/simple-momentpicker.png?circle-token= a8f56261048d7fd84862e210b7e3b884f4ac4166)
A simple, swift and customizable date/time picker based on simple-module
Designed for both mouse and keyboard intereaction.
-
Download the latest release, or via Bower.
You should also get these dependencies: jQuery, momentjs and simple-module
-
Import js/css file to your code
<link rel="stylesheet" href="path/to/momentpicker.css"/> <script type="text/javascript" src="path/to/jquery.js"></script> <script type="text/javascript" src="path/to/module.js"></script> <script type="text/javascript" src="path/to/moment.js"></script> <script type="text/javascript" src="path/to/momentpicker.js"></script>
The plugin can also be loaded as AMD or CommonJS module.
-
Then you can run it like:
simple.momentpicker({ el: '#time' });
el: null inline: false valueFormat: 'YYYY-MM-DD HH:mm:ss' formatSplit: ' ' cls: '' viewOpts: date: disableBefore: null disableAfter: null
Option | Value | Default | Description |
---|---|---|---|
el | selector/jQuery Obejct | null | a input element to initial momentpicker, necessary |
inline | boolean | false | if set true, will append momentpicker after el |
valueFormat | string | 'YYYY-MM-DD HH:mm' | momentjs's format string, set input's value format |
displayFormat | string | 'YYYY-MM-DD HH:mm' | momentjs's format string, set input's display format, only available when inline false |
formatSplit | string | ' ' | A split sign for displayFormat to differentiate date and time view |
cls | string | 'datetime-picker' | the class name add to momentpicker dom |
viewOpts | obejct | - | the options passed to views, only date's disableBefore and disableAfter provided |
Please refer to demo to get more details.
-
setMoment()
set momentpicker's date, could be date string or moment obeject.
-
getMoment()
get a clone of momentpicker's moment
-
getValue()
get value of momentpicker
-
destroy()
destroy momentpicker, reset all.
-
select
triggered when selected a date/time, the only argument is an event object.