node2:/var/www/html/js#cat h37.html
<img id="example" src="images/example.jpg" alt="A bolt of lightning"
onclick="console.log('At ' + formatDate(new Date()) + ' BOOM!');" />
<script>
function formatDate(date) {
return (date.getHours() < 10 ? '0' : '') + date.getHours() +
':' + (date.getMinutes() < 10 ? '0' : '') + date.getMinutes() +
':' + (date.getSeconds() < 10 ? '0' : '') + date.getSeconds() +
'.' + (date.getMilliseconds() < 10 ? '00' : (date.getMilliseconds() < 100 ? '0' : '')) +
date.getMilliseconds();
}
</script>
![](https://img-blog.csdnimg.cn/20190218094511408.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3poYW95YW5namlhbjcyNA==,size_16,color_FFFFFF,t_70)