Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8958837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:18:26+00:00 2026-06-15T15:18:26+00:00

Hello, how can I add an HH:MM time to a li tag based on

  • 0

Hello, how can I add an HH:MM time to a li tag based on a predefined start time?

Background: I have a dance scheduling program that lists dance entries in an unordered list. Through jQuery UI, the user can rearrange the dance routines and when finished, they can display the timing of each routine in the day’s dance schedule. Each dance routine is either 3, 6 or 30 mins in length and I’m storing this length in an attribute on the li tag (incorrectly, I know). The start of day is 8:00:00 AM, and I’d like to add the time to each routine based on their length, the dance routines before it, and the start of day.

Here is an example of the PHP li code from my loop that prints out all of the entries. I’d like to store the time of the routine in the span id=’etimeXXX’. So for example, the following code in my loop:

<ul id="sortable2">
...

$step2 .= "<li id='e".$e[entry_id]."' class='cat entry' lang='$length'>\n"
. "<span class='entry_time' id='etime".$e[entry_id]."'></span>"
. strtoupper($performance_title)]
. "</li>\n";

...
</ul>

…would output something like:

  • 8:03:00 AM Twinkle Twinkle
  • 8:06:00 AM Pie in the Sky
  • 8:09:00 AM Challenge
  • I am trying to use something like the following to display the time, but it isn’t working:

    function createDanceTimes() {   
        var start_time = new Date("March 1, 2013 08:00:00");
    
        var h = start_time.getHours();
        var m = start_time.getMinutes();
    
        var entry_length = 0;
        var cur_time = m;
    
        $("#sortable2 li[id]").each(function(index) {           
            entry_length = $(this).children('span[id^="etime"]').attr('lang');
    
            m=m+entry_length;
    
            $(this).children('span[id^="etime"]').text(m);
        });
    }
    

    Any help would be much appreciated!

    • 1 1 Answer
    • 0 Views
    • 0 Followers
    • 0
    Share
    • Facebook
    • Report

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Forgot Password?

    Need An Account, Sign Up Here

    1 Answer

    • Voted
    • Oldest
    • Recent
    • Random
    1. Editorial Team
      Editorial Team
      2026-06-15T15:18:28+00:00Added an answer on June 15, 2026 at 3:18 pm

      using data-* attributes (HTML5 godsend goodness), it can keep it simpler:

      <ul id="sortable2">
      //...
      <?php
      $performance_title = strtoupper($performance_title);
      $step2 .= <<<HTML
        <li data-time='{$e['entry_id']}' data-length='{$length}' class='cat entry'>
          <span class='entry_time'></span>
          $performance_title
        </li>
      HTML;
      ?>
      //...
      </ul>
      
      function createDanceTimes() {   
        var start_time = new Date();
      
        start_time.setHour(8);
        start_time.setMinute(0);
      
        $("#sortable2 li[data-time]").each(function(index) {           
          var 
            $this = $this;
      
          start_time.setMinute(start_time.getMinute() + parseInt($this.data('length'), 10));
      
          $(this).find('span.entry_time').text((start_time.getHour()) + ':' + (start_time.getMinute())); // this will deal with minutes that get past 60, and will convert to a new hour automatically
        });
      }    
      

      Since I don’t know what is the current format you are using for your times, I’m just trying my best guess

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    I have: localStorage.xxx = JSON.stringify([[something,hello],[something2,hello2]]); . How can i add a new array in
    Hello all how can I create jar file of my project that is created
    hello, how can i set cookies like 'last_visit' if the user have more than
    I am looking for the prototypical 'Hello World' program that creates a Mathematica Notebook
    I will appreciate if I can have a hello world example of how can
    Hello everybody and thanks for interest some time ago i have started to use
    I have the function bellow. I want to add support for iso8601 time format
    Hello I want to click a button that will add a new button to
    I have an issue where every time I try to run a project (that
    Hello i can't import the R with the layouts resources from my app this

    Explore

    • Home
    • Add group
    • Groups page
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help
    • SEARCH

    Footer

    © 2021 The Archive Base. All Rights Reserved
    With Love by The Archive Base

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.