Javascript 日期比较

<script type="text/javascript">
//mydate yyyy-MM-dd 格式
function CompareWithTody(mydate) 
{ 
var stoday = new Date(); 
var syear =Number(stoday.getYear().toString()); //在firefox下得再加1900
var smonth = (stoday.getMonth()+1).toString(); 
var sday = stoday.getDate().toString(); 
if(smonth.length == 1) 
{ 
smonth = "0"+smonth; 
} 
if(sday.length == 1) 
{ 
sday = "0"+sday; 
} 
 var strToday = syear+"\/"+smonth+"\/"+sday; 
var d1=new Date(Date.parse(mydate));//转化成日期格式以后,再进行比较
var d2=new Date(Date.parse(strToday));
return d1>d2
}
</script>

你可能感兴趣的:(JavaScript)