www.webdeveloper.com
Results 1 to 3 of 3

Thread: Getting time and date on a file name

  1. #1
    Join Date
    Feb 2005
    Posts
    50

    Getting time and date on a file name

    This javascript which I'm using works with a webcam to record a video.

    The end result, after the file is recorded, generates a file name, as you can see from the code below: Video+video_id.

    I recorded a file, and the script named the end-result file: Video1335806296490.flv. I understand that the time and date is in this file name, but it's hard to decipher what the time and date of the recording is.

    Can you help me with some code so as to make the the month, day, year and time appear more common and easily readable when a file name is generated? Here's the script I'm using currently:

    Code:
    <script type="text/javascript">
    var video_id = get_id();
    var filename = get_parm('filename');
    if(filename == '' || filename == null)
    {
    filename = 'Video'+video_id;
    }
     
    var flashvars = {
    filename: filename,
    rtmpPath: "rtmp://xxxxxxxxxxxxxxx",
    finishURL: "videoplayer.htm?filename="+filename,
    };
    var params = {
    menu: "false",
    scale: "noScale",
    allowScriptAccess: "always",
    bgcolor: "#000000"
    };
    var attributes = {
    id:"webcamrecording"
    };
    swfobject.embedSWF("recording.swf", "recording", "620", "470", "9", "expressInstall.swf", flashvars, params, attributes);
     
    function get_id()
    {
    var newDate = new Date();
    return newDate.getTime();
    }
     
    function get_parm(name)
    {
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+name+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec( window.location.href );
    if( results == null )
    {
    return "";
    }
    else
    {
    return results[1];
    }
    }
     
    </script>
    Thanks.

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    use iso string. it's WAY more human readable than unix time, and it sorts with a plain-text sort (no arg to [].sort()).


    Code:
    function get_id()
    {
    var newDate = new Date();
      return newDate.toISOString().split(".")[0].replace(/[^\dT]/g,"")
    }
    
    get_id()//=="20120724T201403"

  3. #3
    Join Date
    Feb 2005
    Posts
    50

    Thanks

    Thanks for the reply.

    Can help me to integrate it into my original posting code?
    I don't know anything about iso string.
    Thanks any assistance will be appreciated.

Thread Information

Users Browsing this Thread

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

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