Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    May 2007
    Posts
    162
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Any way to get JS lastmodified in local time?

    Is there a best practice to get a lastmodified in local time vs. GMT?

    Here's the code:
    Code:
    var xmlhttp = new XMLHttpRequest();
    
        xmlhttp.open("GET", "parks.xml", true);
        xmlhttp.send();
        xmlhttp.onreadystatechange = function() {
    
            if(this.readyState == 2) {
    
             
    	    var updated = (xmlhttp.getResponseHeader("Last-Modified"));
    	    //alert(updated);
    	    document.getElementById('xml_modified').innerHTML = updated;
    
    	    
    
            }
        }
    Code:
    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,
    S

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,280
    Thanks
    12
    Thanked 343 Times in 339 Posts
    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)
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •