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:
Source: https://momentjs.com/docs/#/parsing/utc/
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
npm install moment
import moment from 'moment';
moment().format();
Resource: https://momentjs.com/docs/#/use-it/node-js/