Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hjortur17's avatar

Format date using moment or vue

I have this date Sat Sep 21 2019 00:00:00 GMT+0000 (Greenwich Mean Time) and I want to format it to be 21/10/19. Does anyone know how to format this using moment.js or vue?

This dates comes from VC-Calendar

0 likes
5 replies
tykus's avatar
tykus
Best Answer
Level 104

A moment instance can be formatted like this:

moment().format('DD/MM/YY')
Cronix's avatar

All of the date/time formatting options are also in the docs: https://momentjs.com/docs/#/displaying/

console.log(moment('Sat Sep 21 2019 00:00:00 GMT+0000 (Greenwich Mean Time) ').format('DD/MM/YY'));

result: 20/09/19 (for me, in my current local timezone)

audunru's avatar

A quick tip, the localized formatting options are pretty neat if you need to support multiple languages. Check the section "Localized formats" in the link @cronix gave you.

If you can live with selection of formats moment offers, such as moment().format('L') it makes it very easy to offer the right date format for different locales.

Please or to participate in this conversation.