But that's why the context of the question is important. It's not clear from your comment, but I'd give a different answer if the question was strictly academic in nature (reinventing the wheel) or focused on practical work realities (use a library).

Even using a library isn't that practical. It may be the zeitgeist in JavaScript but that doesn't mean it's actually a good idea. Nobody remembers left-pad? If you're writing Java or Python then checking if your date class can already do it is a good idea.