You don't need a script to do this. Under the Type menu, there is a 'Text Variables...' submenu. This will let you define text variables, and place them into text boxes. There is a preset variable called 'Output Date', which will display the current date (MM/dd/yy) when a PDF is output. If you want to display the time as well, under 'Text Variables...', go to 'Define...', and you can define your own. Under 'Type', select output date, and add any variable data you want. The format for time and date should look something like this:
hh:mm:ss MM/dd/yy
I've found that Text Variables don't update in the display very consistantly, but I just tested this, and regardless of the displayed value, the output PDF has the correct time and date.
If you want to control text variables with javaScript, check out the TextVariable(s) and TextVariableInstance(s) classes.
As a side note, text variables work fine if you want date/time, page, etc, but I really wish they would add a bit more functionality, especialy with things like seperation name, color profile, and PDF output profile. It would be a huge timesaver to have all of this type of metadata be easily inserted.