1. 程式人生 > >jquery獲取當前日期

jquery獲取當前日期

  1. <!DOCTYPE html>  
  2. <html lang="zh-CN"> 
  3. <head> 
  4. <meta charset="utf-8"> 
  5. <title>網頁標題-www.divcss5.com</title> 
  6. <meta name="keywords" content="關鍵字" /> 
  7. <meta name="description"
     content="此網頁描述" /> 
  8. </head> 
  9. <body> 
  10. <div class="current-time"></div>
  11. </body> 
  12. <script>
  13. setInterval(function(){
  14. var now=new Date();
  15. var time=now.getFullYear()+"-"+((now.getMonth()+1)<10?"0":"")+(now.getMonth()+1)+"-"+(now.getDate()<10?"0":"")+now.getDate();
  16. $(".current-time").text(time);
  17. },1000)
  18. </script>
  19. </html>