Category: Moment JS
-
Examples
Till now, we have learnt many concepts in MomentJS. This chapter gives you further examples for a better understanding. Display Date Range Between Two Dates This is an example which displays the dates between two given dates. We want to display all the dates between 2014-05-01 to 2014-05-16. We have used date query isSameOrAfter, date addition and date format to…
-
Plugins
Plugins are extended features added on MomentJS. MomentJS is an open source project and many plugins are found in MomentJS which are contributed by its users and available using Node.js and GitHub. This chapter discusses some of the calendars plugins and date formats plugins available in MomentJS. Calendar Plugins This section discusses two types of…
-
Utilities
In MomentJS, you can change or customize the output as per the requirement using normalize units and invalid methods. You can also set your own custom validation on the moment object. Observe the following table for more information − Sr.No. Method & Syntax 1 Normalize Unitsmoment.normalizeUnits(String); 2 Invalidmoment.invalid(Object);
-
Durations
MomentJS provides an important feature called durations which handles length of time for given units. In this chapter, you will learn this in detail. Methods Available with Durations The following table shows the methods available with duration for different units to be used with moment duration − Method Syntax Creating moment.duration(Number, String);moment.duration(Number);moment.duration(Object);moment.duration(String); Clone moment.duration().clone(); Humanize…
-
Customization
MomentJS allows to add customization to the locale created. This chapter discusses them in detail. The following list shows the customizations possible on localization − Sr.No. Localization & Description 1 Month NamesYou can add month names to the locale customization. 2 Month AbbreviationThis method helps in customizing the month abbreviations. 3 Weekday NamesThis method helps in…
-
Internationalization
Internationalization is one of the important features in MomentJS. You can display Date and Time based on localization, in other words, based on the country/region. The locale can be applied to specific moment if required. This chapter discusses in detail about how to make apply locale globally, locally, work with locale using Node.js, in browser,…
-
Date Queries
MomentJS provides methods to query the date/time for leap year, date comparison, date validation etc. This chapter discusses them in detail. Methods for Querying Date in MomentJS The following table shows methods available in MomentJS and their syntax for querying date − Method Syntax Is Before moment().isBefore(Moment|String|Number|Date|Array);moment().isBefore(Moment|String|Number|Date|Array, String); Is Same moment().isSame(Moment|String|Number|Date|Array);moment().isSame(Moment|String|Number|Date|Array, String); Is After moment().isAfter(Moment|String|Number|Date|Array);moment().isAfter(Moment|String|Number|Date|Array, String);…
-
Formatting Date and Time
MomentJS provides formats to display date in different ways. There are methods available which tells the time from a given moment, from the current moment, difference between two moments etc. It can display date in JSON format, Array, Object, String etc. Methods to Format Date and Time The following table shows a list of methods…
-
Manipulate Date and Time
MomentJSprovides various methods to manipulate Date and Time on the moment object. This chapter deal with all such methods in detail. Methods to Manipulate Date and Time The following table shows the methods available in MomentJS which helps in manipulating the Date and Time as required − Sr.No. Method & Syntax 1 Addmoment.add() 2 Subtractmoment.subtract()…
-
Getter/Setter
MomentJS has many methods to get/set the date inputs. Get will allow us to read the required input unit and set will allow to modify the input unit. This chapter discusses in detail the get/set methods to be used on the moment. The following table shows the get/set methods available − Method Syntax Millisecond moment().millisecond(Number)moment().millisecond();moment().milliseconds(Number);moment().milliseconds();…