using JavaScript to retrieve an image's date or time value

Posted on 2003-03-02
Medium Priority
Last Modified: 2012-05-04
I'm running a webcam and I was wondering if there was a more dynamic way in which I could fetch the time or date of an image file remotely using JavaScript...  eg: it's "last modified" or similiar value.  I don't think it's possible outside some obvious cgi, asp, etc. deal but wondering if someone knows something I don't and if there is some obscure JavaScript method for getting a file's info?
Question by:Stendec
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 30

Expert Comment

ID: 8054060
i don't think javascript can do that. using a server-side script is a better choice. take a look a this link,


Expert Comment

ID: 8054923
Just a suggestion, but perhaps you could create a function that would execute every "n" seconds and would increment some sort of a count that you could tack onto the end of your image, like:

<img src="pic" + count + ".jpg">

Bear in mind, this is only a guide & I don't have much time to write your function, but best of luck with trying.


Author Comment

ID: 8055803
Thanks Wakie...

That's how I'd set up things normally for a cam doodad, which I'm sure is what you were getting at, having the images loaded up with a timestamp as part of the image files title.  Problem is the client I'm doing a site for has a CCTV deal and program that doesn't/can't stamp the image title (dumb!).  Add to that their hosting service setup doesn't allow for any CGI, etc (again, super dumb!).  Hence why I was looking for a possible workaround using JavaScript via the browser.  I think if they're serious about properly instituting this webcam they'll have to break down and "enhance" their hosting service so I can get jiggy with some CGI etc and do this properly.  I'll leave the question open a touch longer just to see what other suggestions if any are out there.  Though I'm thinking "third" was right, can't be done w/ clientside JavaScript.
WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.


Expert Comment

ID: 8055910
It is possible to get a file's modified date using JavaScript, but information is only returned accurately when the file is on the local computer.

The last modified date can be found in the document.lastModified variable.

Author Comment

ID: 8056322
Forgot about that one... Thanks Plop.

That only works for the document's "time stamp" as far as I can tell, not for any of the images in it?

Expert Comment

ID: 8056558
Hi Stendec,

Perhaps you could set your webcam to overwrite the existing image file? I haven't had any experience with webcams whatsoever. But, you may be able to create a simple meta refresh if it was possible.


Accepted Solution

memerot earned 150 total points
ID: 8058837
"get jiggy with some CGI" <- Dude that's hilarious!

The only way you may be able to do it is with ActiveX

But if the host doesn't support any other server side scripting, I don't know if you can do this either.  Only client-side approach I can see though.  Once you make your ActiveX object, it's just like using the file system object in ASP.

Otherwise....if they could upload a basic html page that just contained the image, then you could use the lastmodified approach in a page with a whole bunch of iframs pointing to those documents.  Sorry... that's all i got.  Go on and get jiggy with your bad self :)

Author Comment

ID: 8059515

tested the following:

    theX = new ActiveXObject("Scripting.FileSystemObject");
    theFile = theX.GetFile("test_foobar.gif");

Seems to work!  Though it does pop up a warning dialog regarding the ActiveX in IE.  I think there might be a workaround to that though(?).  Didn't even think to use ActiveX, thanks memrot! quick thinking! I'll consider the matter closed at this point.

I'm still going to get them to modify their hosting service to something more substantial and ultimately do this correctly, but for the timebeing this will do fine...

Author Comment

ID: 8059521
And by the way, tahnks to all of you for the input! Wakie, Plop, Third, Memerot...

Appreciate the effort!

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question