![]() |
VOOZH | about |
The moment().min() method is used to return the minimum (or the most distant past) Moment of the given array of Moment objects. It will return the Moment instance of the current time if no argument is passed.
Syntax:
moment().min( Moment[] );
Parameters: This method accepts a single parameter as mentioned above and described below:
Return Value: This method returns the minimum Moment of the given array of Moment objects.
Note: This will not work in the normal Node.js program because it requires an external moment.js library to be installed globally or in the project directory.
Moment.js can be installed using the following command:
Installation of moment module:
npm install moment
The below examples will demonstrate the Moment.js moment().min() Method.
Example 1:
Output:
The three Moments are: Mon Jul 11 2022 01:12:38 GMT+0530 Sun Jun 26 2022 01:12:38 GMT+0530 Thu Jun 16 2022 01:12:38 GMT+0530 The minimum of the Moments from the above is: Thu Jun 16 2022 01:12:38 GMT+0530
Example 2:
Output:
The three Moments are: Mon Jul 11 2022 01:12:38 GMT+0530 Mon Jul 11 2022 01:12:18 GMT+0530 Mon Jul 11 2022 01:12:38 GMT+0530 The minimum of the Moments from the above is: Mon Jul 11 2022 01:12:18 GMT+0530
Reference: https://momentjs.com/docs/#/get-set/min/