datejs学习

把http://code.google.com/p/datejs/wiki/APIDocumentation上面的例子写了一下,有一些跟官方网站上的好像不太一样。
<script type="text/javascript" src="date-zh-CN.js"></script>

 <script type="text/javascript">
	var showDate=function(){
		//document.getElementById("demo").innerHTML=Date.today();
		//document.getElementById("demo").innerHTML=Date.today().add(7).days();
		//document.getElementById("demo").innerHTML=Date.today().getDayName();
		//document.getElementById("demo").innerHTML=new Date(2007,2,1).getMonthName(true);
		//document.getElementById("demo").innerHTML=Date.today().getDayOfYear();//从这一年的1月1号到今天的天数
		//document.getElementById("demo").innerHTML=new Date(2007,2,1).getDayOfYear();

		//document.getElementById("demo").innerHTML=Date.today().getWeekOfYear();
//		document.getElementById("demo").innerHTML=(2).days().fromNow();
//		document.getElementById("demo").innerHTML=(3).days().ago();
//		var n=12;
//		document.getElementById("demo").innerHTML=n.weeks().fromNow();
//
	//document.getElementById("demo").innerHTML=(2).months().fromNow();
//		var d1=Date.parse('07.15.2007');
//		document.getElementById("demo").innerHTML=(30).days().after(d1);
		//document.getElementById("demo").innerHTML=Date.parse('today');
		//document.getElementById("demo").innerHTML=Date.parse('tomorrow');//需要使用双引号才行,是一个字符串
		//document.getElementById("demo").innerHTML=Date.parse('8-Dec-2007');//格式不对

		//document.getElementById("demo").innerHTML=Date.getDaysInMonth(2007, 0);//月份的天数,月份是从0-11的数
		//document.getElementById("demo").innerHTML=Date.getMonthNumberFromName('July');
		//document.getElementById("demo").innerHTML=Date.today().isLeapYear();
		//document.getElementById("demo").innerHTML=new Date(2004,1,29).isLeapYear();
		//document.getElementById("demo").innerHTML=Date.today().add({days:5,months:1});

		//document.getElementById("demo").innerHTML=Date.today().compareTo(new Date().clearTime());

		//document.getElementById("demo").innerHTML=Date.today().isWeekday();

		//document.getElementById("demo").innerHTML=Date.today().moveToFirstDayOfMonth();
		//document.getElementById("demo").innerHTML=Date.today().moveToLastDayOfMonth(); 

		//document.getElementById("demo").innerHTML=Date.parse("2007,11,11");//Date.parse ( String dateString ) : Date 
		//document.getElementById("demo").innerHTML=Date.parseExact("6/15/2007", "M/d/yyyy");//这个还不清楚
		//document.getElementById("demo").innerHTML=Date.today().set({ day: 15, hour: 8 }); //set ( Object object ) : Date 
		//document.getElementById("demo").innerHTML=Date.today().toString("yyyy");
		//document.getElementById("demo").innerHTML=Date.today().toString("yyyy-M-d");//toString ( String format ) : String 日期的格式化显示
		//document.getElementById("demo").innerHTML=new Date().toString("HH:mm");

		document.getElementById("demo").innerHTML=Date.validateHour(15); //Date.validateHour ( Number hour ) : Boolean 
		

	}		
  </script>
 <body onload=showDate()>
 
  <div id="demo">123</div>
 </body>

你可能感兴趣的:(Google)