Date formatting in Javascript using date-fns library, nicely illustrated. Thanks, Dom {2024-11-04}
@zoki53882 ай бұрын
title should also mention "using library"
@joel-rg8xm2 ай бұрын
Feedback: Your videos are getting longer and providing less worthy knowledge eventually, I hardly don't stay t'until the end no more. Sorry to say this.
@tapiomakinen2 ай бұрын
Javascript Date object API is, in my opinion, so rich, that I fail to see the benefit of using (and learning) several-hundred-kilobyte library. Why not just learn the real thing? The reason I comment, is that often I see apps or web pages that download 20 to 30 different libraries, some of which are barely used in the code. If nothing else, it's waste of precious energy and time in the long run. Nothing wrong with the video, though ;)
@Vzome2 ай бұрын
For one reason, I haven't found a good built-in method to format a Date in the current timezone in ISO format.
@tapiomakinen2 ай бұрын
@@Vzome I get your point, it would get a bit cumbersome in this specific case, but maybe this is what you mean: new Date(Date.now()-(60000*new Date().getTimezoneOffset())).toISOString();
@CWhitmer220152 ай бұрын
@@Vzome I tend to agree with @tapiomakien. Lots of folks importing an entire library for a single function. For toISOString() in local time, try creating a new date offset to local time then to toISOString() var tzoffset = (new Date()).getTimezoneOffset() * 60000; //offset in milliseconds var localISOTime = (new Date(Date.now() - tzoffset)).toISOString().slice(0, -1); console.log(localISOTime) // => '2015-01-26T06:40:36.181' The .slice(0,1) is to take the trailing Z off the string as it is not UTC time. Just so it won't be confusing.
@User948Z7Z-w7nАй бұрын
That means you haven't used it in enterprise environment. For personal side projects using built in Date object is probably fine. Because who cares about timze zone quirks in a project that nobody uses
@Vzome2 ай бұрын
Nice content, but why use the non-module script tag? Why not just a CDN import directly in your main.js? Use of outmoded global scripts makes me less confident in your content, honestly.