您的位置:首页 > 其它

flex如何获取到当前月份的最后一天

2012-02-02 09:51 260 查看
<?xml version="1.0" encoding="utf-8"?> 
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="defaultYm()"> 
 
<mx:Script> 
 <![CDATA[
 	import mx.controls.Alert; 
  import mx.states.SetStyle; 
  import flash.sampler.NewObjectSample; 
  
  private function  defaultYm():void{ 
     var nowDate:Date = new Date();
     var nowyear:String = nowDate.getFullYear().toString();
     var nowmonth:String = (nowDate.getMonth()+1).toString().length == 1?"0"+(nowDate.getMonth()+1).toString():(nowDate.getMonth()+1).toString();
   
     var lastdaysOfMonth:String = daysOfMonth(nowyear+nowmonth);  
     Alert.show("当月最后一天"+lastdaysOfMonth);
  } 
  
   function daysOfMonth(Month):String{   
	   var currentMonth=new Date(Month.substring(0,4),Month.substring(4,6),1);   
	   var lastMonth=new Date(Month.substring(0,4),Month.substring(4,6)-1,1);   
	   var diffDays=currentMonth-lastMonth;     
	   return ""+(diffDays/( 24 * 60 * 60 * 1000));   
}   
 ]]> 
</mx:Script> 
  
</mx:Application>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: