var timestamp = new Date().getUTCMilliseconds();
var now = new Date();
timestamp =now.getFullYear().toString();
// 2011
timestamp += (now.getFullMonth < 9 ? '0' : '') + now.getFullMonth().toString();
// JS months are 0-based, so +1 and pad with 0's
timestamp += (now.getDate < 10) ? '0' : '') + now.getDate().toString();
次に、そのタイムスタンプを入力に追加します
<input name="timestamp" id="input" type="hidden"/>
それから:
document.querySelector('#input').value = timestamp;
編集:最終コード
<script>
document.onreadystatechange = function()
{
if(document.readyState == "interactive")
{
var now = new Date();
timestamp =now.getFullYear().toString();
// 2011
timestamp += (now.getFullMonth < 9 ? '0' : '') + now.getFullMonth().toString();
// JS months are 0-based, so +1 and pad with 0's
timestamp += (now.getDate < 10) ? '0' : '') + now.getDate().toString();
document.querySelector('#input').value = timestamp;
}
}
</script>
このスクリプト タグをドキュメントの一番下に配置します。