ChristianBucher Posted September 22 Share Posted September 22 Dear Community, I have a question regarding the 24h format in the event calendar. I was able to accomplish this using the following code. <script> (function () { if (window.NodeList && !NodeList.prototype.forEach) { NodeList.prototype.forEach = Array.prototype.forEach; } if (document.readyState == 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } function init() { var elements = document.querySelectorAll('.event-time-12hr-start, .event-time-12hr-end, .event-time-12hr'); if(elements) { elements.forEach(function (el) { var time = el.textContent; if (time.length < 9) { timenew = time.replace("PM",""); timenew = timenew.replace("AM",""); dateold = new Date("2013/01/01 " + time); datenew = new Date("2013/01/01 " + timenew); if (time.indexOf("PM")) { if (dateold.getHours() > 12) { datenew.setHours (datenew.getHours() + 12); } } n = datenew.getMinutes(); el.textContent = (datenew.getHours() + ":" + (n < 10 ? '0' + n : n)); } }); } } })(); </script> Now, unfortunately, the problem is that this only works on desktop devices (laptop/PC etc..). As soon as I open the page on a mobile device, the time switches to (AM/PM). Would someone here possibly have advice on how I could change this by means of code? And would it also be possible to enter the start time without end time in the time setting of the events? Kind regards and thanks for your help. Christian Bucher Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment