xxxxxxxxxx
WARNING: Considering using Moment in your project?
There may be better modern alternatives.
Check: https://momentjs.com/docs/#/-project-status/recommendations/
xxxxxxxxxx
moment().format('YYYY-MM-DD');// FECHA DE ACTUAL: 2022-12-04
moment().format('DD-MM-YYYY');// FECHA DE ACTUAL: 04-12-2022
moment('2022-12-12').add(10, 'days').format('DD-MM-YYYY');//SUMA 10 DIAS: 22-12-2022
xxxxxxxxxx
npm install moment --save # npm
yarn add moment # Yarn
Install-Package Moment.js # NuGet
spm install moment --save # spm
meteor add momentjs:moment # meteor
bower install moment --save # bower (deprecated)
xxxxxxxxxx
moment().format('YYYY/MM/DD, h:mm:ss a'); // March 21st 2023, 8:02:47 am
moment().format('dddd'); // Tuesday
moment().format("MMM Do YY"); // Mar 21st 23
moment().format('YYYY [escaped] YYYY'); // 2023 escaped 2023
moment().format(); // 2023-03-21T08:02:47+05:30
xxxxxxxxxx
moment().format('MMMM Do YYYY, h:mm:ss'); // March 24th 2021, 4:02:53 pm
moment().format('dddd'); // Wednesday
moment().format("MMM Do YY"); // Mar 24th 21
moment().format('YYYY [escaped] YYYY'); // 2021 escaped 2021
moment().format(); // 2021-03-24T16:02:53-03:00
xxxxxxxxxx
moment().format('MMMM Do YYYY, h:mm:ss a'); // May 22nd 2020, 6:00:23 pm
moment().format('dddd'); // Friday
moment().format("MMM Do YY"); // May 22nd 20
moment().format('YYYY [escaped] YYYY'); // 2020 escaped 2020
moment().format(); // 2020-05-22T18:00:23+05:30
xxxxxxxxxx
moment().format('MMMM Do YYYY, h:mm:ss a'); // April 18th 2023, 7:24:45 pm
moment().format('dddd'); // Tuesday
moment().format("MMM Do YY"); // Apr 18th 23
moment().format('YYYY [escaped] YYYY'); // 2023 escaped 2023
moment().format(); // 2023-04-18T19:24:45+06:00
xxxxxxxxxx
moment().format(); // "2014-09-08T08:02:17-05:00" (ISO 8601, no fractional seconds)
moment(2021-06-03 02:30:00.690Z).format("dddd, MMMM Do YYYY, h:mm:ss a"); // "Sunday, February 14th 2010, 3:25:50 pm"
moment().format("ddd, hA"); // "Sun, 3PM"
moment().format("[Today is] dddd"); // "Today is Sunday"
moment('gibberish').format('YYYY MM DD'); // "Invalid date"
xxxxxxxxxx
moment().format('MMMM Do YYYY, h:mm:ss'); // January 14th 2022, 10:29:57 am
moment().format('dddd'); // Friday
moment().format("MMM Do YY"); // Jan 14th 22
moment().format('YYYY [escaped] YYYY'); // 2022 escaped 2022
moment().format(); // 2022-01-14T10:29:57+05:00