//日期转字符串 function toStringData(date){ var year = date.getFullYear(); var month =(date.getMonth() + 1).toString(); var day = (date.getDate()).toString(); var hours = (date.getHours()).toString(); var minutes = (date.getMinutes()).toString(); var time = (date.getSeconds()).toString(); if (month.length == 1) { month = "0" + month; } if (day.length == 1) { day = "0" + day; } var dateTime = year + "-" + month + "-" + day+" "+hours+":"+minutes+":"+time; return dateTime; } //页面加载后执行 window.οnlοad=function (){ var time=new Date(); var dataTime=toStringData(time); $("#time").val(dataTime); }
html加载页面后运行js代码,时间转换
最新推荐文章于 2021-06-02 22:40:47 发布