How to get current date in JavaScript? (date formatting)
Hi everyone! I just started learning JavaScript and came across a seemingly simple task: I need to display the current date on a web page in "dd.mm.yyyy" format. I know there's a `Date` object, but when I write `new Date()`, the console outputs something like "Mon Oct 14 2024 15:30:00 GMT+0300". That's not what I need at all.
I tried using `getDate()`, `getMonth()`, `getFullYear()` methods, but I get numbers, and I have to manually add zeros before days and months if they are less than 10. Also, I don't understand why `getMonth()` returns 9 for October instead of 10.
Please advise how to correctly and elegantly get the current date in the required format? Maybe there's a ready-made method or library? Or do I need to write my own formatting function every time?
Here's an example