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:
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!
using
data-*attributes (HTML5 godsend goodness), it can keep it simpler:Since I don’t know what is the current format you are using for your times, I’m just trying my best guess