Home >Web Front-end >JS Tutorial >How to display the current time in js (code)
The content of this article is about how js implements the display of the current time (code). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
<html> <head> <title>js实现当前日期显示</title> </head> <body style="text-align: center"> <div> <span id="curTime" style="font-size: 18px;color: #00be67"></span> </div> </body> <script type="text/javascript" charset="utf-8"> $(function(){ var date = new Date(); var weekDay = ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]; var year = date.getFullYear(); var month = date.getMonth()+1; var day = date.getDate(); var week = weekDay[date.getDay()]; $("#curTime").html(year+"年"+month+"月"+day+"日      "+week); }) </script> </html>
Related recommendations:
js display time js display last modified time_javascript skills
JS jQuery displays boot time (Accurate to seconds)
#JS implements real-time display of time
The above is the detailed content of How to display the current time in js (code). For more information, please follow other related articles on the PHP Chinese website!