时间比较
来源:互联网 发布:sql 00933 编辑:程序博客网 时间:2024/06/10 01:56
- <script language="JavaScript">
- function getInfo(a,b)
- {
-
- if(compare(a,b)){
- alert("a>=b");
- }else
- {
- alert("a<b");
- }
- }
- function compare(a,b)
- {
- alert("a = "+a);
- alert("b = "+b);
- var time_a = a.split('-');
- var time_b = b.split('-');
- alert(time_a[0]);
- if(parseInt(time_a[0])<parseInt(time_b[0]))
- {
- return false;
- }
- else if(parseInt(time_a[1])==parseInt(time_b[1]))
- {
- if (parseInt(time_a[1])<parseInt(time_b[1]))
- {
- return false;
- }
- else if(parseInt(time_a[1])==parseInt(time_b[1]))
- {
- if(parseInt(time_a[2])<=parseInt(time_b[2]))
- {
- return false;
- }
- }
- }
- return true;
- }
- </script>