JavaScript momentjs and converting to unix gives wrong date moment js convert unix timestamp to date,moment js convert

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

see http://jsfiddle.net/7Equ2/4/

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.

I tried

moment(start).utc().unix(), 

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?

Answer:1

I am wondering if there is some better way to communicate between distant components. In my case I have structure like this: <div> <History /> <Board> <BoxesView> ...

I am wondering if there is some better way to communicate between distant components. In my case I have structure like this: <div> <History /> <Board> <BoxesView> ...

  1. passing data from child to parent react
  2. passing data from one component to another
  3. passing data from child to parent angular
  4. passing data from parent to child
  5. passing data from controller to view
  6. passing data from php to javascript
  7. passing data from child to parent vue
  8. passing data from activity to fragment
  9. passing data from view to controller in mvc
  10. passing data from laravel to vue
  11. passing data from child to parent react hooks
  12. passing data from flask to javascript
  13. passing data from html to javascript
  14. passing data from rails to react
  15. passing data from child to child react
  16. passing data from one fragment to another
  17. passing data from controller to view laravel
  18. passing data from one lambda to another
  19. passing data from jsp to servlet
  20. passing data from iframe to parent

-- Hi ! Reader, if you are not comfortable with Tumblr, please tell me, I will give more details! I had some issues on my tumblr page with the default theme 'Optica'. When I post an embed SoundCloud ...

-- Hi ! Reader, if you are not comfortable with Tumblr, please tell me, I will give more details! I had some issues on my tumblr page with the default theme 'Optica'. When I post an embed SoundCloud ...

I would like to dynamically remove or disable a <style> tag that looks like this <style type="text/css" id="cssx/portal/simple-sidebar.css" designtr="cssx/portal/simple-sidebar.css"> #...

I would like to dynamically remove or disable a <style> tag that looks like this <style type="text/css" id="cssx/portal/simple-sidebar.css" designtr="cssx/portal/simple-sidebar.css"> #...

  1. find style attribute using jquery
  2. jquery find style attribute
  3. jquery find style attribute value
  4. javascript find style attribute
  5. find element by style attribute jquery
  6. jquery find inline style attribute

I really need help. I am a newbie programmer and really not sure how can i do this in joomla. I need to create a pop up or iframe that pass variable from the parent page. Basically what is to happen ...

I really need help. I am a newbie programmer and really not sure how can i do this in joomla. I need to create a pop up or iframe that pass variable from the parent page. Basically what is to happen ...

  1. create popup iframe javascript
  2. create iframe popup
  3. how to create iframe popup window
  4. how to create iframe popup window in asp.net