JavaScript time conversion processing function
/** * 将格式为yyyy-MM-dd hh:mm:ss.S的字符串转为Date * @param dateString 时间字符串 */ function convertToDate(dateString){ return new Date(dateString.replace(/\-/g,"/")); } /** * 比较时间 * @param date1 * @param date2 */ function compareDate(date1, date2) { return date1.getTime() - date2.getTime(); }
The above is all the content shared with you in this article, I hope you will like it.