I want to know what is the different between:
moment('2021-12-12', 'YYYY-MM-DD')
to this one:
moment('2021-12-12).format('YYYY-MM-DD)
When you use the format method in moment, you convert the date to the string with the desired format. But when you pass the desired format as the second argument to the moment method, you do not actually convert the data type. But you want that your date to be in a written format. This is a big difference between first option and second option that you wrote.
For more info you can read this