document.addEventListener("DOMContentLoaded", function () { const utcDateElements = document.querySelectorAll('.date-utc'); console.log("utcDateElements",utcDateElements); utcDateElements.forEach(function (element) { const utcDateString = element.getAttribute('data-utc-date'); console.log("utcDateString",utcDateString); const dateParts = utcDateString.split('-'); console.log("dateParts",dateParts); const utcDate = new Date(`${dateParts[1]}-${dateParts[0]}-${dateParts[2]}`); console.log("utcDate",utcDate); element.textContent = utcDate.toLocaleString(); }); }); that code workes fine on local but on staging give me invaild date text I have to sent datetime from server that is in format 05-01-2024 12:03:54