首页 > 代码库 > js获取当前时间并格式化

js获取当前时间并格式化

                        var dates = new Date();                        var years = dates.getFullYear();                        var months = dates.getMonth()+1;                           var days = dates.getDate();                        var hours = dates.getHours();                          var mins =dates.getMinutes();                            var secs = dates.getSeconds();                        //document.write(years+"-"+months+"-"+days+" "+hours+":"+mins+":"+secs);                                         var message_date=(years+"-"+months+"-"+days+" "+hours+":"+mins+":"+secs);

 

js获取当前时间并格式化