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.

4 comments

  1. Youre so cool! I dont suppose Ive read anything like this before. So nice to find somebody with some original thoughts on this subject. realy thank you for starting this up. this website is something that is needed on the web, someone with a little originality. useful job for bringing something new to the internet!

  2. The security benefits of disabling JavaScript are dubious, and you will give up so much of the modern web if you do. You can whitelist websites to only run JavaScript on certain websites, but that’s a never-ending task that will take precious time.

    1. I definitely agree with you on that. I did read some research on how often people disable Javascript and it’s actually rare these days. Most server side calls are via AJAX these days and disabling scripts makes a website uselses. I get why people do it, but at the same time, there’s line of being over paranoid. My opinion at least.

      ….I couldn’t decide if your comment was spam or not.

Leave a Reply

Your email address will not be published. Required fields are marked *