www.webdeveloper.com
Results 1 to 15 of 18

Thread: Extract Date and Time Stamp of a file/image

Threaded View

  1. #16
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,266
    Eureka ! I found how to obtain a date with Opera ...
    To avoid that the browser tries to read the image lastModified in the cache, you have only to call
    Code:
    dt=LastModUsingHeader('upload.jpg?'+Math.random()); 
    // or to modify the function 
    function LastModUsingHeader(U) {
        var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest;
        X.open('GET', U+'?'+Math.random(), false);
       	try{ X.send();}catch(y){}
      	var dt=X.getResponseHeader('Last-Modified'); 
    	return new Date(dt).toLocaletring(); 
    }
    // to write
    <p>Image uploaded: <i id="ImageDate"></i></p>
    
    <script type="text/javascript">
    document.getElementById('ImageDate').innerHTML=LastModUsingHeader('upload.jpg'); 
    </script>
    This could be applied too to the image src...
    It would be better to have a DOCTYPE for the page (See W3C) and to display meta tags to control the cache (See this page) to choose a Meta tag...
    HTML Code:
    <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
    <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
    Otherwise the users could have difficulties to update the page...
    Last edited by 007Julien; 11-16-2011 at 04:57 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles