Moment.js moment.second() Method Last Updated : 20 Mar, 2023 Comments Improve Suggest changes Like Article Like Report The moment().second() Method is used to get the seconds from the current time or to set the seconds. Syntax: moment().second(); // or moment().seconds(); Parameters: This method accepts a single parameter number that you want to set seconds then you will require an additional parameter: Number: It ranges from 0 to 59 and is used to set seconds in a variable. Return Value: This function returns the current time in seconds. Note: This will not work in the normal Node.js program because it requires the moment.js library to be installed. Moment.js can be installed using the following command: npm install moment Example 1: Getting the current time in seconds. JavaScript // Acquiring the plugin const moment = require('moment'); let sec = moment().second(); console.log("Current seconds Time:", sec); Output: Current seconds Time: 18 Example 2: Setting seconds of time. JavaScript // Acquiring the plugin const moment = require('moment'); let sec = moment().second(55); console.log("Seconds Time:", sec); Output: we can see the seconds in time. Seconds Time: Moment<2020-08-05T20:59:55+05:30> Comment More infoAdvertise with us Next Article Moment.js moment().month() Method T taran910 Follow Improve Article Tags : JavaScript Moment.js Similar Reads Moment.js moment().set() Method The moment().set() method is used to set the given unit of time to the Moment object. The unit can be specified in all the recognized variations of the unit including its plural and short forms. The time can also be set using an object that contains all the needed units of time together. Syntax: mom 2 min read Moment.js moment().toJSON() Method The moment().toJSON() method is used to get the JSON format of the Moment object. During the serialization process, the ISO8601 format would be used for converting the duration into a format suitable for the JSON output. Syntax: moment().duration().toJSON(); Parameters: This method does not accept a 1 min read Moment.js moment().zone() Method The moment().zone() method is used to specify the given Moment object's time zone offset in minutes. An optional parameter can be passed that preserves the current time value and only changes the timezone offset. Syntax: moment().zone( Number | String ); Parameters: This method accepts a single para 2 min read Moment.js moment().month() Method The method `moment().month()` in Moment.js is employed to retrieve or modify the month of the Moment object. It's important to note that the months in Moment.js are zero-indexed. Consequently, the valid range for months is 0 to 11, where 0 corresponds to January and 11 to December. If a value greate 2 min read Moment.js moment().toDate() Method The moment().toDate() method is used to return the Moment object as a native JavaScript object. This Date object can then be used with the native Date methods or for support in other libraries. Syntax: moment().toDate(); Parameters: This method does not accept any parameters: Return Value: This meth 2 min read Moment.js moment.duration().seconds() Method The moment().duration().seconds() method is used to get the number of seconds of the duration. This number of seconds is calculated as a subset of a minute, therefore having a value between 0 and 59. Syntax: moment().duration().seconds(); Parameters: This method does not accept any parameters. Retur 2 min read Like