您现在的位置: 万盛学电脑网 >> 程序编程 >> 脚本专题 >> javascript >> 正文

JavaScript时间转换处理函数

作者:佚名    责任编辑:admin    更新时间:2022-06-22

 JavaScript时间转换处理函数

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 /** * 将格式为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(); }