How to convert minutes to hours/minutes and add various time values together using jQuery?

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.

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”?

HTML:

<span class="totalMin">90</span> Minutes

<span class="convertedHour">0</span> Hours
<span class="convertedMin">0</span> Minutes

jsFiddle: http://jsfiddle.net/ExFBD

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?

HTML:

<span class="hour-1 hour">1</span> hour
<span class="min-1 min">30</span> min

<span class="hour-2 hour">2</span> hour
<span class="min-2 min">45</span> min

<span class="hour-3 hour">2</span> hour
<span class="min-3 min">15</span> min


<span class="totalHour">0</span> hour
<span class="totalMin">0</span> min

jsFiddle: http://jsfiddle.net/DX9YA/

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?

84 thoughts on “How to convert minutes to hours/minutes and add various time values together using jQuery?”

  1. I have been surfing online more than three hours today, yet
    I never found any interesting article like yours.
    It’s pretty worth enough for me. In my view, if all
    web owners and bloggers made good content as
    you did, the internet will be a lot more useful than ever before.

    Reply
  2. whoah this weblog is magnificent i love studying
    your articles. Keep up the good work! You realize, many individuals are searching round for this info,
    you could aid them greatly.

    Reply
  3. Howdy just wanted to give you a quick heads up.
    The text in your post seem to be running off the screen in Opera.
    I’m not sure if this is a formatting issue or something to
    do with browser compatibility but I thought I’d post to let
    you know. The design and style look great though!

    Hope you get the issue fixed soon. Cheers

    Reply
  4. You could certainly see your expertise in the
    work you write. The world hopes for even more passionate
    writers like you who aren’t afraid to say how they believe.
    All the time go after your heart.

    Reply
  5. Thanks for your personal marvelous posting!
    I actually enjoyed reading it, you happen to be a great author.
    I will be sure to bookmark your blog and may come back from
    now on. I want to encourage you to definitely continue your
    great job, have a nice weekend! scoliosis surgery https://0401mm.tumblr.com/ scoliosis surgery

    Reply
  6. Please let me know if you’re looking for a author for
    your weblog. You have some really great articles and I believe I would be a good asset.

    If you ever want to take some of the load off, I’d absolutely love to write some material for your blog in exchange for a link
    back to mine. Please shoot me an e-mail if interested.
    Cheers! ps4 games https://j.mp/3z5HwTp ps4 games

    Reply
  7. Go to 1this website to see how to get free diamonds on cooking fever

    gh45kkm
    Cooking Fever is a lot more fun when you have unlimited diamonds.If you love mobile games like this you need to check out the site above

    Reply

Leave a Comment