Jump to content

Javascript Dates


Guest Reveneous

Recommended Posts

Guest Reveneous

Hi all,i wonna know if its possible to subtract 2 dates with javascript. One you set manual(1) and one the date of today(2).I want to make a time that shows how much time still to go to time. So time(1) - time(2)Thanks allot!

Link to comment
Share on other sites

Read about the Date object here: http://www.w3schools.com/js/js_obj_date.aspThe getTime() method returns a timestamp in milliseconds. Simple arithmetic can convert that to seconds, hours, days etc.The documentation does not explain that you can pass Date() a timestamp and get a time in the future or past. So if you got a timestamp for now, subtracted/added a certain number of milliseconds, you could pass the result to Date() and get a date object for some time in the past or future.Be sure to pass the milliseconds to Date() as a string, not a number.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...