标题 | Javascript获取时间函数 |
内容 | Javascript获取时间函数,具体代码如下: //获取时间 function curDateTime() { var d = new Date(); var year = d.getFullYear() + ""; var month = d.getMonth() + 1; var date = d.getDate(); var day = d.getDay(); var Hours = d.getHours(); //获取当前小时数(0-23) var Minutes = d.getMinutes(); //获取当前分钟数(0-59) var Seconds = d.getSeconds(); //获取当前秒数(0-59) var curDateTime = year; if (month > 9) { curDateTime = curDateTime + month; } else { curDateTime = curDateTime + "0" + month; } if (date > 9) curDateTime = curDateTime + date; else curDateTime = curDateTime + "0" + date; if (Hours > 9) curDateTime = curDateTime + Hours; else curDateTime = curDateTime + "0" + Hours; if (Minutes > 9) curDateTime = curDateTime + Minutes; else curDateTime = curDateTime + "0" + Minutes; if (Seconds > 9) curDateTime = curDateTime + Seconds; else curDateTime = curDateTime + "0" + Seconds; //alert(curDateTime); return curDateTime; } |
随便看 |
|
在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。