获取阴历(农历)和当前日期的js代码(2)

function GetCurrentDateTime() { var d = new Date(); var year = d.getFullYear(); var month = d.getMonth() + 1; var date = d.getDate(); var week = d.getDay(); var hours = d.getHours(); var minutes = d.getMinutes(); var seconds = d.getSeconds(); var ms = d.getMilliseconds(); 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; var weekday = ""; if (week == 0) weekday = "星期日"; else if (week == 1) weekday = "星期一"; else if (week == 2) weekday = "星期二"; else if (week == 3) weekday = "星期三"; else if (week == 4) weekday = "星期四"; else if (week == 5) weekday = "星期五"; else if (week == 6) weekday = "星期六"; curDateTime = curDateTime + " " + weekday; return curDateTime; }

页面调用代码:

<script language="JavaScript" type="text/javascript" src="https://www.jb51.net/getToday.js"></script>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgwwyd.html