You can get the time and date that a user is using a device with JavaScript. Fliplet comes pre-installed with a library called moment.js that makes manipulating dates easier. To get more information on moment.js please visit

When using moment.js, you can specify the format you’d like the date to be in. For example, the following code would return a date with the years first (4 digit years) then the month and day specified by two digits (eg 2020-03-18)

var date = moment().format('YYYY-MM-DD');

You can find out more about the different options here.

You can also get the time in a similar way to the dates. The following code displays the time with colons separating it eg: 16:20:13

var time = moment().format('HH:MM:SS');

Different display options for time can also be found here.

If you’re working with multiple time-zones you may want to get the UTC rather than a user’s local time. You can do this in the following way:

var time = moment.utc().format('HH:MM:SS');
Was this article helpful?