提醒自已別再忘記了XD
/*Date control*/ function convStrToDate(dateStr){ var parseDateObj = parseDate(dateStr); //.replace(/-/g,"/"); // $.console("parse:" + parseDateObj); var convDate = new Date(Date.parse(parseDateObj)); return convDate; } function convDateToStr(dateObj) { var year = dateObj.getFullYear(); var month = dateObj.getMonth() + 1; var date = dateObj.getDate(); var hour = dateObj.getHours(); var minute = dateObj.getMinutes(); var second = dateObj.getSeconds(); return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second; } function parseDate(dateStr) { var a = $.map(dateStr.split(/[^0-9]/), function(s) { return parseInt(s, 10) }); return new Date(a[0], a[1] - 1 || 0, a[2] || 1, a[3] || 0, a[4] || 0, a[5] || 0, a[6] || 0); }
沒有留言:
張貼留言
留個話吧:)