0

I am using the Twtitter Bootstrap Calendar and have an issue with the code they have provided. It's within the Modal overlay to display an event details.

Specifically the issue is that the working out of the event start and end times is not showing the first 0 witihn the minutes column. So for example - the event.date_start for this event is 1413993600000 (I assume that is in milliseconds), so that worked out into date and time format should be: 22 October, 2014 at 17:00 - what the Twitter code outputs however is 22 October 2014, at 17:0 - You can see the missing first 0 - this happens with any time that is within the first 9 minutes...

The code the modal template is using to format the event.date_start string is below - can anyone advise how to get it not to miss the leading 0 from minutes 1-9 so they read 01, 02 - 09 rather than 1,2-9 as per current // thanks

<%  event.date_start = new Date(parseInt(event.start));
    event.date_end = new Date(parseInt(event.end)); %>

<div id = "event-meta" style="margin-bottom: 20px;">
    <span>Starts on <%= event.date_start.getDate() %> <%= calendar.locale["m" + event.date_start.getMonth()] %> <%= event.date_start.getFullYear() %>, at <%= event.date_start.getHours() %>:<%= event.date_start.getMinutes() %> <i class = "icon-time"></i></span><br />
    <span>Ends on <%= event.date_end.getDate() %> <%= calendar.locale["m" + event.date_end.getMonth()] %> <%= event.date_end.getFullYear() %> at <%= event.date_end.getHours() %>:<%= event.date_end.getMinutes() %> <i class = "icon-time"></i></span><br />
</div>
Cœur
  • 37,241
  • 25
  • 195
  • 267
dubbs
  • 1,167
  • 2
  • 13
  • 34

1 Answers1

0

Figured it out myself:

<script>

var StartminsWorkedout = "<%= event.date_start.getMinutes() %>";

if (StartminsWorkedout <= 9){
StartminsWorkedout = "0" + StartminsWorkedout;
}

//alert(StartminsWorkedout);
$('#startmins').html(StartminsWorkedout);


var EndminsWorkedout = "<%= event.date_end.getMinutes() %>";

if (EndminsWorkedout <= 9){
EndminsWorkedout = "0" + EndminsWorkedout;
}

//alert(EndminsWorkedout);
$('#endmins').html(EndminsWorkedout);

</script>
dubbs
  • 1,167
  • 2
  • 13
  • 34