moment-cli
v0.0.4
Published
CLI for printing dates via momentjs.
Downloads
118
Readme
moment-cli
CLI for printing dates via momentjs.
Install
$ npm install -g moment-cli
Usage
$ moment --help
Usage: moment <input> [options]
Options:
-h, --help output usage information
-V, --version output the version number
-i --inputFormat <format> e.g: "MM-DD-YYYY". Special handling for "unix".
-f --format <format> Output format. See momentjs docs for options.
-t --timeago Output in `timeago` format (fromNow).
-c --calendar Output in `calendar` format.
-u --unix Output a unix timestamp (secs since Epoch).
-j --js Ouput a JavaScript timestamp (ms since Epoch).
Examples
Output current time
$ moment
2013-03-11T16:45:21-07:00
Output current time in a custom format
$ moment -f "dddd, MMMM Do YYYY, h:mm:ss a"
Monday, March 11th 2013, 4:46:42 pm
Convert a JavaScript timestamp (ms since Epoch) to a custom format
$ moment 1318781876406 -f MM/DD/YYYY
10/16/2011
Convert a Unix timestamp to a formatted date
$ moment 1318781876 -i unix
2011-10-16T09:17:56-07:00
Convert a date string into a JavaScript timestamp
$ moment 03/11/2011 -j
1299830400000
Convert a date string into a unix timestamp
$ moment 03/11/2011 -u
1299830400
Formatting Cheat-sheet
Developed by Terra Eclipse
Terra Eclipse, Inc. is a nationally recognized political technology and strategy firm located in Aptos, CA and Washington, D.C.
License: MIT
Copyright (C) 2012 Terra Eclipse, Inc. (http://www.terraeclipse.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.