momentjs time code example
Example 1: momentjs
npm install moment --save
yarn add moment
moment.locale(); // en
moment().format('LT'); // 8:49 AM
moment().format('LTS'); // 8:49:26 AM
moment().format('L'); // 10/13/2020
moment().format('l'); // 10/13/2020
moment().format('LL'); // October 13, 2020
moment().format('ll'); // Oct 13, 2020
moment().format('LLL'); // October 13, 2020 8:49 AM
moment().format('lll'); // Oct 13, 2020 8:49 AM
moment().format('LLLL'); // Tuesday, October 13, 2020 8:49 AM
moment().format('llll'); // Tue, Oct 13, 2020 8:49 AM
Example 2: moment now format
var date = moment().format('MM/DD/YYYY');
Example 3: momentjs utcoffset
moment().utcOffset() // will output 60 (for example)
Example 4: javascript moment
m = moment('2013-03-01', 'YYYY-MM-DD')
Example 5: moment js print date
moment(testDate).format('MM/DD/YYYY');
Example 6: moment format heure
var time = "15:30:00";
var formatted = moment(time, "HH:mm:ss").format("LT");
console.log(formatted);
//it will return 3:30 PM