JavaScript and Dates

As a programmer, sometimes I get very frustrated working with dates. Sometimes they can be a butt. In any language. I had a lot of issues with the PHP DateTime object, the Date object and mktime. They are all similar and very different. Well lately, I’ve had the task of creating a calendar using the jQuery plugin called FullCalendar and integrate it into our system at work. Alright then. No worries. Well, I started to work with the JavaScript Date object. This was a first for me really. The events would be saved in a database and the FullCalendar plugin would display it. No worries right? Wrong. I did plenty of research on StackOverflow. Every time I would try to display a date with a time, the time and/or date would be off. I would console.log it out just fine. HOW CAN THE TIME BE OFFFF!?!!?!?!? After hours of headache, I found out why. When you turn a time string to a JavaScript date object, it turns it into UTC time. WTF!? I want my timezone!!! You can’t just add to the time either. I mean what about PDT or PST and and and…BAH!! I found another way. Use the .toISOstring. This will turn your date time into something you can get the time easier. I just substring the times I want.

Stupid JavaScript and their UTC time.