Moment.js Parsing Moment Clone Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will learn how to clone and parse moment.js objects. Cloning and Parsing Moment.js Objects: All Moment.js objects are parsable and clonable. Cloning a moment could be done, both implicitly and explicitly. Installation: npm install moment Syntax: moment(Moment); // Moment is a moment.js object Parameters: It accepts a moment as a parameter Return value: It returns a clone of a moment passed as an argument. Example 1: In this example, we will implicitly clone a moment. main.js: JavaScript const moment = require('moment'); var a = moment([2022]); var b = moment(a); a.year(2000); console.log(b.year()); Step to run the application: Open the terminal and type the following command. node main.js Output: 2022 Example 2: In this example, we will explicitly clone a moment. main.js: JavaScript const moment = require('moment'); var a = moment([2022]); var b = a.clone(); a.year(2000); b.year(); Step to run the application: node main.js Output: 2022 Reference: https://momentjs.com/docs/#/parsing/moment-clone/ Comment More infoAdvertise with us Next Article Moment.js Parsing Moment Clone D dishebhbhayana Follow Improve Article Tags : Technical Scripter Web Technologies Node.js Technical Scripter 2022 Moment.js Moment.js-Parse +2 More Similar Reads Moment.js Parsing Object Moment.js is a date library for JavaScript that parses, validates, manipulates, and formats dates. We can use the moment() function passed with an object to parse dates represented as objects. The moment() function is used to create a moment using an object. Syntax: moment({unit: value, ...}) Parame 1 min read Moment.js Parsing Now Moment.js is a date library for JavaScript that parses, validates, manipulates, and formats dates. We can use the moment() function passed to get the current date and time. The moment() function is used to create a moment with the current date and time. Syntax: moment() | moment(undefined) | moment( 1 min read Moment.js Parsing Date Moment.js is a date library for JavaScript that parses, validates, manipulates, and formats dates. We can use the moment() function passed with an object to parse dates represented as Date object. The moment() function is used to create a moment using a Date object. Syntax: moment( Date ) Parameters 1 min read Moment.js moment().unix() Function The function moment().unix() retrieves the count of seconds since the Unix Epoch, which is a reference point for denoting a specific moment in time. Unix time serves as a system for timestamping.Syntax:moment().unix();Parameters: This function has no parameters. Return Value: This function returns t 1 min read Moment.js moment().to() Function The moment().to() function is used when users want to display a moment in relation to a time other than now. This function calculates the time to a particular date in Node.js. Syntax: moment().to(Moment|String|Number|Date|Array, Boolean); Parameters: This function has two parameters, first one is o 2 min read Like