js 时间格式化成字符串
程序员文章站
2024-02-01 20:24:52
我用的简单的直接的字符串格式转化 ......
我用的简单的直接的字符串格式转化
function gettimestr() { var date = new date(); var year = date.getfullyear(); var month = date.getmonth() + 1; var day = date.getdate(); var hours = date.gethours(); var minutes = date.getminutes(); if (month.length == 1) { month = "0" + month; } if (day.length == 1) { day = "0" + day; } if (hours.length == 1) { hours = "0" + hours; } if (minutes.length == 1) { minutes = "0" + minutes; } var d = year + "-" + month + "-" + day + " " + hours + ":" + minutes; return d; }
上一篇: php自动获取字符串编码函数mb_detect_encoding
下一篇: 正则表达式元字符解析