pepelepew1962 Posted December 5, 2012 Share Posted December 5, 2012 Hello: I found this great calendar program that has 1 main fault. It does not display 24hrs with the leading zero, as in 09:00 instead of 9:00. I think the below code is the root of the problem. Can anyone help me here please as I know no JScript: //Time Picker function tPicker(timeFieldId) { var timeField = $(timeFieldId); var hhmm; //compute tpicker coordinates (beneath timeField) var x = timeField.offsetLeft + timeField.offsetWidth + 22; var y = timeField.offsetTop - 95; //deal with elements inside tables and such var parent = timeField; while (parent.offsetParent) { parent = parent.offsetParent; x += parent.offsetLeft; y += parent.offsetTop ; } //If not present, create tpDiv, move it to x,y and toggle visibility var tpDiv = createDiv("tpDiv", x, y); //draw the timepicker table; the timeField object will receive the time var html='<div class="tpFrame">'; var apm = /\s*a/i.exec(tFormat); if (apm != null) { var am = String(apm).replace("a","am").replace("A","AM"); var pm = String(apm).replace("a","pm").replace("A","PM"); } if (apm != null) { html += '- AM -'; } for (var i=7;i<24;i++){ if (i==7) { html += '<div class="tpAM">'; } if (i==12 && (apm != null)) { html += '- PM -'; } if (i==12) { html += '<div class="tpPM">'; } if (i==18) { html += '<div class="tpEM">'; } for (var j=0;j<60;j += 15) { if (apm != null) { hh = i; ampm = (hh < 12) ? am : pm; if (hh >= 13) { hh -= 12; } hhmm1 = String(hh) + ":" + String("0" + j).slice(-2) + ampm; hhmm2 = String("0" + hh).slice(-2) + ":" + String("0" + j).slice(-2); } else { hhmm1 = hhmm2 = String("0" + i).slice(-2) + ":" + String("0" + j).slice(-2) } html += '<a class="tpPick" href="#" onclick="updateTimeField(\''+timeFieldId+'\', \''+hhmm1+'\');">'+hhmm2+'</a>'; if (j<45) { html += ' '; } } html += (i==11 || i==17 || i==23) ? '</div>' : '<br>'; } html += '</div>'; tpDiv.innerHTML = html; } function updateTimeField(timeFieldId, timeString) { var timeField = $(timeFieldId); if (timeString) { timeField.value = timeString; } var tpDiv = $("tpDiv"); tpDiv.style.visibility = "hidden"; tpDiv.style.display = "none"; timeField.focus(); } Quote Link to comment https://forums.phpfreaks.com/topic/271623-jscript-24hrs-with-leading-zero/ Share on other sites More sharing options...
gizmola Posted December 5, 2012 Share Posted December 5, 2012 Yes, I do know how to fix this, but I have no intention of doing that work for you, as there's nothing in it for me or this community to just change the code of a library you didn't write to your specifications. That is not what this community exists to do. Perhaps you'll sucker one of the other 20 forums you cross posted this question to into getting an answer, or you could actually dig into javascript and learn a little bit. By the way it doesn't help to obfuscate your source as you did here, which only makes you come off as deceptive and underhanded. Quote Link to comment https://forums.phpfreaks.com/topic/271623-jscript-24hrs-with-leading-zero/#findComment-1397647 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.