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

Discussion in 'Javascript' started by Fabrizio, Oct 5, 2004.

  1. Fabrizio

    Fabrizio Guest

    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
    Fabrizio, Oct 5, 2004
    #1
    1. Advertising

  2. Fabrizio

    McKirahan Guest

    "Fabrizio" <> wrote in message
    news:...
    > 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.
    McKirahan, Oct 5, 2004
    #2
    1. Advertising

  3. JRS: In article <E2z8d.335366$Fg5.101771@attbi_s53>, dated Tue, 5 Oct
    2004 15:26:28, seen in news:comp.lang.javascript, McKirahan
    <> posted :

    > 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.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
    Dr John Stockton, Oct 5, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?WGF2aWVy?=

    display time needed for creation of the page

    =?Utf-8?B?WGF2aWVy?=, Feb 9, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    361
    =?Utf-8?B?WGF2aWVy?=
    Feb 9, 2006
  2. Chris Berg
    Replies:
    0
    Views:
    786
    Chris Berg
    Oct 27, 2003
  3. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,250
    Michael Borgwardt
    May 30, 2004
  4. Keith Cochrane
    Replies:
    2
    Views:
    610
    Keith Cochrane
    Aug 6, 2006
  5. Replies:
    11
    Views:
    211
    Justin Collins
    Aug 16, 2006
Loading...

Share This Page