I guess we shouldn’t be surprised because JavaScript is a language full of fun surprises. And furthermore, both computers returned the same result for the toISOString() method!Įither I’m going crazy, or we just typed in the exact same thing on two different computers and got a completely different answer - not to mention one of the computers got my date completely wrong!! Or did it…
toDateString() was Tue Sep 29 2020, while on my server, the result of. Notice anything? On my local computer, the result of. Here’s my local computer (the computer I’m standing at right now in the Eastern part of the United States):Īnd here is the webserver that I run my golf training application on: Imagine this - you‘ve been coding for 8 hours, your brain is a bit tired, and you console.log one of your dates during an intense debugging session:Įnter fullscreen mode Exit fullscreen mode It seems like all the cool kids are using MomentJS these days (or if you’re even cooler - Luxon).ĭon’t worry, I’m not some JavaScript purist here telling you to always work with vanilla JS Date Objects - I just want to work through the core concepts that will make your life with Moment/Luxon much much easier. Most people search for tutorials on JavaScript dates when all they needed was a review of how time works! (including myself)īefore I start reading… What about MomentJS? As you read this post, you’ll realize that the difficult part of JavaScript dates is the non-JavaScript concepts like timezones and formatting standards. JavaScript dates aren’t actually that difficult. And if I had to guess, a few of you reading this are in a similar spot, so cheers to that! ? It took me at least 3 years of programming before I finally sat down to understand this topic. If your dates don’t handle timezones correctly and you end up with an “off by 1” error, your user who missed their job interview is going to be FURIOUS with your app. Furthermore, they might be the least exciting thing to learn about in JavaScript programming.īut what happens if you are building a Todo app - you know, the most overused web application in existence, and you want to add calendar reminder functionality?