How do I get current datetime and format?

Hello,

Using moment JS, to get the current datetime and format I would do this

moment().format("YYYY-MM-DD HH:mm")

What is the equivalent in Framework7

Hi, i dont think f7 has a native date format.

What are my options?

you can use moment, as you were

2 Likes

I’ve had to do this but didn’t want to use moment. I came up with this. Be warned, .padStart is ES8 and the output is UTC.

let now = new Date();
let timestamp = `${now.getUTCFullYear()}-${(now.getUTCMonth()+1).toString().padStart(2, '0')}-${now.getUTCDate().toString().padStart(2, '0')} ${now.getUTCHours().toString().padStart(2, '0')}:${now.getUTCMinutes().toString().padStart(2, '0')}:${now.getUTCSeconds().toString().padStart(2, '0')}`;
// 2018-06-22 14:45:13
1 Like