Javascript and UTC

If you are using the Date.UTC() function in javascript be aware of 2 things

  • It returns the time from 1/1/1970 in milliseconds. So if you are using PHP you need to divide by 1000. This isn't too bad but then
  • When you pass the month parameter in you have to take off 1 as it counts January as 0 and June as 5 etc.

So for June 1 2007 you would do:
Date.UTC(2007,5,1)
How stupid is this! Who in their right mind decided that January would be 0. No other date function on other languages does this! And even though PHP counts arrays from [0] it still manages to make the month parameter start at 1.

This drove me insane for about 10 minutes so this should save others some time.