Format Time Zone Date

I have come accross date conversion format and recently I've been working with Sharepoint, React and Laravel. I 've noticed the time stamp string shows as UTS, for example:

2023-01-11T21:35:20.712Z

As you can tell from the time stamp above, it contains a Z at the end. So how can we convert this time to the local time zone?

To do this, you can use a very useful utility called Moment.js, https://momentjs.com

Some example code:

let dateString = "2023-01-11T21:35:20.712Z";
let offSet = (480 + -60 + 0);
let localDate = moment.utc(dateString).utcOffset(offSet);
console.log(`LINE 40 localDate=`, localDate.format('LLLL');

Source: https://momentjs.com/docs/#/parsing/utc/

Multiple Locale Support

moment.locale();         // en
moment().format('LT');   // 2:50 PM
moment().format('LTS');  // 2:50:15 PM
moment().format('L');    // 01/16/2023
moment().format('l');    // 1/16/2023
moment().format('LL');   // January 16, 2023
moment().format('ll');   // Jan 16, 2023
moment().format('LLL');  // January 16, 2023 2:50 PM
moment().format('lll');  // Jan 16, 2023 2:50 PM
moment().format('LLLL'); // Monday, January 16, 2023 2:50 PM
moment().format('llll'); // Mon, Jan 16, 2023 2:50 PM

https://momentjs.com

Node.JS Install

npm install moment

Usage:

import moment from 'moment';
moment().format();

Resource: https://momentjs.com/docs/#/use-it/node-js/