Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to convert minutes to hours/minutes and add various time values together using jQuery?
    text
    copied!<p>There are a couple parts to this question. I am not opposed to using a jQuery plugin if anyone knows of one that will accomplish what I want done.</p> <p><strong>Q1 - How do I convert minutes into hours and vise versa? For example how would I convert 90 minutes into 1 hour and 30 minutes. In the code below how would I get "totalMin" converted and displayed in "convertedHour" and "convertedMin"?</strong></p> <p>HTML:</p> <pre><code>&lt;span class="totalMin"&gt;90&lt;/span&gt; Minutes &lt;span class="convertedHour"&gt;0&lt;/span&gt; Hours &lt;span class="convertedMin"&gt;0&lt;/span&gt; Minutes </code></pre> <p>jsFiddle: <a href="http://jsfiddle.net/ExFBD" rel="noreferrer">http://jsfiddle.net/ExFBD</a></p> <p><strong>Q2 - How would I add up a group of time slots? For example, How would I add 1 hour 30 mins, 2 hours 45 mins and 2 hour 15 mins together?</strong></p> <p>HTML:</p> <pre><code>&lt;span class="hour-1 hour"&gt;1&lt;/span&gt; hour &lt;span class="min-1 min"&gt;30&lt;/span&gt; min &lt;span class="hour-2 hour"&gt;2&lt;/span&gt; hour &lt;span class="min-2 min"&gt;45&lt;/span&gt; min &lt;span class="hour-3 hour"&gt;2&lt;/span&gt; hour &lt;span class="min-3 min"&gt;15&lt;/span&gt; min &lt;span class="totalHour"&gt;0&lt;/span&gt; hour &lt;span class="totalMin"&gt;0&lt;/span&gt; min </code></pre> <p>jsFiddle: <a href="http://jsfiddle.net/DX9YA/" rel="noreferrer">http://jsfiddle.net/DX9YA/</a></p> <p><strong>Q3 - How would I take a time value (3 hours and 30 mins) and add it to a real time stamp such as 10:30 AM? How would I take AM vs PM into account?</strong> </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