re: Formatting dates with JavaScript VIEW POST


Thorough coverage!

Reminds me of something I started building for a client for a similar purpose, but as we had limited needs, I never fleshed it out as much.

Am curious why you used the if/else for adding the leading 0s, and not:

d.getDate().toString().padStart(2, '0')

Only IE doesn't support padStart...


No particular reason. padStart works well for this.

code of conduct - report abuse