比较时间先后顺序可以使用字符串
var a = "2014-08-08";
var b = "2014-09-09";
console.log(a>b, a<b); // false true
console.log("21:00"<"09:10"); // false
console.log("21:00"<"9:10"); // true 时间形式注意补0
因为字符串比较大小是按照字符串从左到右每个字符的 charCode来的,但所以特别要注意时间形式注意补0
比较时间先后顺序可以使用字符串
var a = "2014-08-08";
var b = "2014-09-09";
console.log(a>b, a<b); // false true
console.log("21:00"<"09:10"); // false
console.log("21:00"<"9:10"); // true 时间形式注意补0
因为字符串比较大小是按照字符串从左到右每个字符的 charCode来的,但所以特别要注意时间形式注意补0
本文标题:字符串比较时间先后
本文链接:https://www.haomeiwen.com/subject/owurmctx.html
网友评论