Click to See Complete Forum and Search --> : creation date


makal
01-03-2003, 05:28 AM
I'm itelian so i'm sorry for my english.
Is there a function (in js language) that show the creation date of a document.
Thank you.
Bye

khalidali63
01-03-2003, 05:53 AM
doesnt look like it,since document creation would be related to OS and JavaScript( as of today) have no ability to interact with the OS directly.You'd need any other hard core programming language to do this, such as C/C++ or java.

Khalid

Charles
01-03-2003, 06:07 AM
You can, however, use JavaScript to get at the date and time of the last modification of the file, but it will fail for one in ten users so do not use this method if the modification date is anything more than fluff. The other problem is that the document.lastModified property is in an unfriendly format. The way around this is to make a Date object from it and then implicitly call Date.toString(). As you might expect the value returned by Date.toString() is also not very friendly but you can overwrite the method to your liking. Thus:

<script type="text/javascript">
<!--
Date.prototype.toString = function () {return [['Sunday,', 'Monday,', 'Tuesday,', 'Wednesday,', 'Thursday,', 'Friday,', 'Saturday,'] [this.getDay()], this.getDate(), ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] [this.getMonth()], this.getFullYear()].join('&nbsp;')}
document.write('revised: ', new Date(document.lastModified))
// -->
</script>