View Full Version : Any way to get JS lastmodified in local time?

12-15-2011, 10:21 PM
Is there a best practice to get a lastmodified in local time vs. GMT?

Here's the code:

var xmlhttp = new XMLHttpRequest();

xmlhttp.open("GET", "parks.xml", true);
xmlhttp.onreadystatechange = function() {

if(this.readyState == 2) {

var updated = (xmlhttp.getResponseHeader("Last-Modified"));
document.getElementById('xml_modified').innerHTML = updated;


and <li id ="bottom_menu"><a href="parks.xml" target = "_blank">XML</a>&nbsp;&nbsp;&nbsp;&nbsp;Updated: <div id = "xml_modified"></li>

Thanks for any help,

12-16-2011, 01:12 AM
if I read my reference right (MDC) the standard methods return the time in locale format. to get the date/time in GMT you have to use methods explicitly containing UTC (like .toUTCString())

besides that, if you only need the Last-Modified header, change the request type from GET to HEAD (which does not return the file itself)