From a simple string, with some valid date format, it will create an object (parse), will validate the string and we can add or delete time, reformat the date and do many more manipulations of the date object in order to do a better display of the information.
Instead of modifying the native
, Moment.js creates a wrapper for the
object. To get this wrapper object, simply call
with one of the supported input types.
prototype is exposed through
. If you want to add your own functions, that is where you would put them.
To use it you just need to remember this function
To get the current date and time, just call
with no parameters.
<span class="keyword">var</span> now = moment();
This is essentially the same as calling
If you want to parse a string you must use it
When creating a moment from a string, we first check if the string matches known ISO 8601 formats, then fall back to
if a known format is not found.
You can find more information about the usage in the library docs.