Set DateTime return format

Is it possible to set the return (not the display or picker) format of DateTime?

I need the “YYYYMMDD” format, like “19761001”.
By default, the component returns a string like “YYYY-MM-DD”.
I know i can use external libraries like “moment”, but it would be a bit overpriced i think.


Hi Moscardini,

You can use regular expression for that.

var date = "1976-10-01";
var newdate = date.replace(/-/g,""); // => "19761001"
1 Like

Date is submitted through a form and I would have liked to avoid changing it.

If there are no other solutions, I will replace the date trying something like that:

1 Like

There is a saying:

You have a problem. You write a regular expression to solve it. Now you have two problems.

Here is a complete working pipe that uses date-fns/format. You should be able to adapt it easily to do what you want.


Thanks for suggestion.


Better than =, "");