Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding hours and minutes to a date with javascript
    text
    copied!<p>I am building a meeting calendar based on time zones around the world. My problem is how to add or subtract the time zone from the user selected date in Javascript.</p> <p>For example, on the select form, the user will select the date from a form: I would then get the results and convert to a date as below...</p> <pre><code>var ldSelectDate = new Date(document.form1.year.value, document.form1.month.value, document.form1.day.value); </code></pre> <p>I would like to add 12 midnight to this object.</p> <p>I then read in an XML that gets the time zone difference in a string between two cities: such as "+0430" for Kabul or "-0400" for New York (on daylight savings time). This is based on GMT,.</p> <p>I then calculate the time zone difference between the two cities: which will return the string of "830". (I assume I have to return this as a date object?). I got this part done returning a string. I'm working with strings.</p> <p>I then want to loop through the 24 hours of the day, set Kabul at 12 midnight and then loop through. I can most likely figure this out - that is, set the date with the whole hours as I loop.</p> <p>My problem is painlessly subtract the "830" from Kabul to see what the meeting time will be in New York.</p> <p>It will be ideal if I can just subtract the hours and the minutes from the Kabul time. I noticed on here someone subtracting the hours in javascript, but not the minutes. BTW, that post didn't work for me.</p> <p>I did this with strings without the minutes, but I mess up with the minutes. There has to be an easier way.</p> <p>I would take a solution in either native Javascript or jQuery.</p> <p>Again, I need to subtract/add the time zone difference in hours and minutes to a certain date.</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload