I am having a bit of trouble getting momentjs to convert a date to unix in the correct way:
var start = new Date(2013,11,2); console.log('Start date: '+start); console.log('Unix date: '+moment(start).unix()); console.log('Unix date 2: '+moment(start).add('hours', 1).unix()); Start date: Mon Dec 02 2013 00:00:00 GMT+0100 (CET) Unix date: 1385938800 Unix date 2: 1385942400
But entering the converted unix date in http://www.onlineconversion.com/unix_time.htm returns Sun, 01 Dec 2013 23:00:00 GMT, whereas adding 1 hour returns the correct unix date. I guess it is because The start date is created in CET (my locale time zone). So I guess I need to pass the start date as UTC, but I have to keep the datevalues (ie. it should still be "Mon Dec 02 2013 00:00:00"). But I cannot figure out how.
but that doesn't seem to make any difference as it still returns Unix date: 1385938800
How do I make it return the correct unix date?