The Easiest Way to Format Dates in JavaScript

  Рет қаралды 1,348

dcode

dcode

Күн бұрын

Пікірлер: 9
@Pareshbpatel
@Pareshbpatel Ай бұрын
Date formatting in Javascript using date-fns library, nicely illustrated. Thanks, Dom {2024-11-04}
@zoki5388
@zoki5388 2 ай бұрын
title should also mention "using library"
@joel-rg8xm
@joel-rg8xm 2 ай бұрын
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.
@tapiomakinen
@tapiomakinen 2 ай бұрын
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 ;)
@Vzome
@Vzome 2 ай бұрын
For one reason, I haven't found a good built-in method to format a Date in the current timezone in ISO format.
@tapiomakinen
@tapiomakinen 2 ай бұрын
@@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();
@CWhitmer22015
@CWhitmer22015 2 ай бұрын
@@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
@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
@Vzome
@Vzome 2 ай бұрын
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.
Two Easy Ways to Compare Dates in JavaScript
8:17
dcode
Рет қаралды 1,2 М.
Вопрос Ребром - Джиган
43:52
Gazgolder
Рет қаралды 3,8 МЛН
Ful Video ☝🏻☝🏻☝🏻
1:01
Arkeolog
Рет қаралды 14 МЛН
Every React Concept Explained in 12 Minutes
11:53
Code Bootcamp
Рет қаралды 866 М.
Reacting to Controversial Opinions of Software Engineers
9:18
Fireship
Рет қаралды 2,1 МЛН
A Modern Monolith with Inertia.js by Grant Holle
54:08
Springfield Devs
Рет қаралды 67
The HTML Boilerplate
12:54
London App Brewery
Рет қаралды 1,4 М.
Microservices are Technical Debt
31:59
NeetCodeIO
Рет қаралды 698 М.
There's Way More to JSON.Stringify Than You Think
9:26
dcode
Рет қаралды 2,9 М.
The Dome Paradox: A Loophole in Newton's Laws
22:59
Up and Atom
Рет қаралды 210 М.
20 Programming Projects That Will Make You A God At Coding
14:27
The Coding Sloth
Рет қаралды 1,5 МЛН
5 JavaScript Console Methods Every Developer Should Know
8:23