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 file was named: Video1335806296490.flv. I understand that the time and date in this file name, is the time and day of the recording expressed in seconds.

Would there be an easy line or two of code that I could add (or change) so that when I see the file name generated, it would be easier to recognize when the file name is created, as in some type of easier to read month and day and year and time of day?

Any assistance will be greatly appreciated. (Or suggest an alternative tweak to make file names more recognizable?)

Thanks.

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

Hi,
Here is a code that you can use in your script to get the date-time from “video_id” .

<script type="text/javascript"><!--
// http://www.coursesweb.net/javascript/
var video_id = 1335806296490;
var date = new Date(video_id);
var year = date.getFullYear();
var month = date.getMonth() + 1;      // "+ 1" becouse the 1st month is 0
var day = date.getDate();
var hour = date.getHours();
var minutes = date.getMinutes();
var secconds = date.getSeconds()

var seedatetime = month+ '.'+ day+ '.'+ year+ ' - '+ hour+ ':'+ minutes+ ':'+ secconds;

alert(seedatetime);        // for test
//-->
</script>

Thanks for that reply, however I don’t know how to integrate that into the code in my posting.
And i’m not sure why you have 1335806296490 in your script.
Any additional clarification/enlightenment would be appreciated.

Hi,
The number 1335806296490 is the value of the variable “video_id” from your script, I thogut, from this code:

filename = 'Video'+video_id;

that variabe contains the number you want to transform in date-time.
If you don’t know how to integrate that code into your script, maybe it is needed to learn some JavaScript.
That example shows you how to get the year, month, day, hour, …, from a number of millisecconds.

Thanks for all the replies. I ended up adding this to the code:
function get_id()
{
var newDate = new Date();
return ’ ‘+parseInt(newDate.getMonth()+1)+’-‘+newDate.getDate()+’-‘+newDate.getFullYear()+’-'+newDate.getTime()
}

My intention was to have a more informative file name when looking at the completed webcam video file list, and it is. But also, for some reason, the file name appears across the bottom of the video itself (briefly). By looking at the code that I had originally posted, can you suggest how I can keep the file name, but without it appearing on the video? Thanks

Also if you’re looking for more information about split functions I put together some information on the topic and I think it could be relevant to you. http://www.verious.com/board/AKumar/javascript-working-split-functions/