Home > Web Front-end > JS Tutorial > JavaScript time conversion processing function_javascript skills

JavaScript time conversion processing function_javascript skills

WBOY
Release: 2016-05-16 16:04:06
Original
1033 people have browsed it

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();
}
Copy after login

The above is all the content shared with you in this article, I hope you will like it.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template