[ionic4] How to get the date and time of the device (i.e. the device on which the app is running)

I want to get the date and time of the device i.e. the time and date of that specific region where the app is getting used. Can some one plz help me?

@lucasbasquerotto

Hi, @pantarmj
try to install
1 - Install via NPM:

npm install moment -S

2 - Import in your Typescript file:

import moment from ‘moment’;

3 - Use in your Typescript file:

let data = moment().format('YYYYMMDD');
let time = moment().format('HHmmss');
console.log('today is: ', data + ' and time: ', time);

Hope this will help you

Thanks

1 Like

it your issue is resolved please mark as solution.