Site Notice
hello, world
Difference between revisions of "Time"
From Project-EPB Commons
([InPageEdit] 没有编辑摘要) |
([InPageEdit] 没有编辑摘要) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | <span onclick=" | + | <html><span id="time" onclick="time()">time</span></html> |
− | <html><script>function time() { | + | <html><script> |
+ | function time() { | ||
var now = new Date(), | var now = new Date(), | ||
− | + | y = now.getFullYear(), m = Number(now.getMonth() + 1), d = Number(now.getDate()); | |
− | + | if (m < 10) m = '0' + m; | |
− | + | if (d < 10) d = '0' + d; | |
− | + | var time1 = y + '-' + m + '-' + d; | |
− | + | $("#time").text(time1); | |
} | } | ||
</script> | </script> | ||
</html> | </html> |
Latest revision as of 15:46, 21 February 2020
<html><span id="time" onclick="time()">time</span></html> <html><script> function time() {
var now = new Date(), y = now.getFullYear(), m = Number(now.getMonth() + 1), d = Number(now.getDate()); if (m < 10) m = '0' + m; if (d < 10) d = '0' + d; var time1 = y + '-' + m + '-' + d; $("#time").text(time1);
} </script> </html>