JavaScript time conversion handler
- 2020-05-27 04:25:49
- OfStack
JavaScript time conversion handler
/**
* The format for yyyy-MM-dd hh:mm:ss.S Is converted to Date
* @param dateString Time string
*/
function convertToDate(dateString){
return new Date(dateString.replace(/\-/g,"/"));
}
/**
* More time
* @param date1
* @param date2
*/
function compareDate(date1, date2) {
return date1.getTime() - date2.getTime();
}
That's all I want to share with you. I hope you like it.