function checkFormat(filePath, acceptFormat) {
var resultBool = false,
ex = filePath.substring(filePath.lastIndexOf(".") + 1);
ex = ex.toLowerCase();
for (var i = 0; i < acceptFormat.length; i++) {
if (acceptFormat[i] == ex) {
resultBool = true;
break;
}
}
return resultBool;
}
function limitTypes() {
var obj = document.getElementById("filePath");
var path = obj.value;
var result = checkFormat(path, ["bmp", "jpg", "jpeg", "png"]);
showTime();
二十七、时间戳、毫秒格式化
function formatDate(now) {
var y = now.getFullYear();
var m = now.getMonth() + 1; // 注意 JavaScript 月份+1
var d = now.getDate();
var h = now.getHours();
var m = now.getMinutes();
var s = now.getSeconds();
return y + "-" + m + "-" + d + " " + h + ":" + m + ":" + s;
}
var nowDate = new Date(1442978789184);
alert(formatDate(nowDate));
二十八、当前日期
var calculateDate = function() {
var date = new Date();
var weeks = ["日", "一", "二", "三", "四", "五", "六"];