javascript to get the creation date and time of the file sent and display it in the html page ?

F

Fabrizio

I have just put a internet webcam that save every 30 seconds a picture
via ftp. I have an html file that display this picture file (the name
of the file is always the same and the webcam delete the old file when
save the new one). The problem is: The webcam don't have the option to
put automatically the date and time when the picture as take. How I
can make a simple JavaScript that get the creation date and time of
the file sent by the webcam and display it in the html page ?
Thank you in advance for your help.
If you like to see it the adress is: http://live.imagea.org

Fabrizio
 
M

McKirahan

Fabrizio said:
I have just put a internet webcam that save every 30 seconds a picture
via ftp. I have an html file that display this picture file (the name
of the file is always the same and the webcam delete the old file when
save the new one). The problem is: The webcam don't have the option to
put automatically the date and time when the picture as take. How I
can make a simple JavaScript that get the creation date and time of
the file sent by the webcam and display it in the html page ?
Thank you in advance for your help.
If you like to see it the adress is: http://live.imagea.org

Fabrizio

Will this help? Watch for word-wrap.

This renames "foto.jpg" to "ccyymmddhhnnss_.foto.jpg".

<html>
<head>
<title>foto.htm</title>
<script type="text/javascript">
var dir = "C:\\Temp\\";
var pix = "foto.gif";
var fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FileExists(dir+pix)) {
var now = new Date();
var ymd = now.getFullYear();
ymd += ((now.getMonth()+101)+"").substr(1,2);
ymd += ((now.getDate()+100)+"").substr(1,2);
ymd += ((now.getHours()+100)+"").substr(1,2);
ymd += ((now.getMinutes()+100)+"").substr(1,2);
ymd += ((now.getSeconds()+100)+"").substr(1,2);
var sav = ymd + "_" + pix;
document.write(dir+sav);
fso.MoveFile(dir+pix, dir+sav);
}
</script>
</head>
<body>
</body>
</html>

Note that an ActiveX security warning will be issued.
 
D

Dr John Stockton

JRS: In article <E2z8d.335366$Fg5.101771@attbi_s53>, dated Tue, 5 Oct
2004 15:26:28, seen in McKirahan
var now = new Date();
var ymd = now.getFullYear();
ymd += ((now.getMonth()+101)+"").substr(1,2);
ymd += ((now.getDate()+100)+"").substr(1,2);
ymd += ((now.getHours()+100)+"").substr(1,2);
ymd += ((now.getMinutes()+100)+"").substr(1,2);
ymd += ((now.getSeconds()+100)+"").substr(1,2);

That looks like a translation of some half-baked code found in a
VBScript newsgroup.

Each line implements a function here often called LZ.

Testing in MSIE4 :
In VBScript, adding 100 and decapitating is the fastest way I know.
In javascript, it is not; my usual way is 40% faster.

with (new Date())
S = ((((getFullYear()*100 + getMonth()+1)*100 + getDate())*100 +
getHours())*100 + getMinutes())*100 + getSeconds()

does the same job rather more simply, if S is then used as a string by
concatenation.

However, the job that it does seems only loosely related to what the OP
asked for.

The WebCam continuously updates a file of fixed name, and it is that
name by which it will be fetched. Fabrizio wants to display when that
file was last modified. A search of the newsgroup FAQ for Last,
Modified, or both would have helped. But see sig line 3 below :
it leads to <URL:http://www.merlyn.demon.co.uk/js-date2.htm#lM>. 2.

ISTM that Fabrizio need only display the lastModified information
discussed there; either the raw string or the string corrected to
international format.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,235
Latest member
Top Crypto Podcasts_

Latest Threads

Top