OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

sum two dates in node.js?

  • Thread starter Thread starter tino
  • Start date Start date
T

tino

Guest
i'm trying to sum two dates.

date1 and date2 are Date() objects.

i read oher questions and googled it.. i tryed this way but it return a negative number

Code:
var sum_millis = date1.getTime()+date2.getTime();

var sum=new Date(sum_millis);

console.log(sum.toString());

date1: 1901-02-01T00:10:00.000Z

date2: 1901-01-31T23:07:23.000Z

result: -4349551357000

what i'm doing wrong?

<p>i'm trying to sum two dates. </p>

<p>date1 and date2 are Date() objects.</p>

<p>i read oher questions and googled it.. i tryed this way but it return a negative number </p>

<pre><code>var sum_millis = date1.getTime()+date2.getTime();

var sum=new Date(sum_millis);

console.log(sum.toString());
</code></pre>

<p>date1: 1901-02-01T00:10:00.000Z</p>

<p>date2: 1901-01-31T23:07:23.000Z</p>

<p>result: -4349551357000</p>

<p>what i'm doing wrong? </p>
 

Latest posts

Top