资讯信息
       宝鸡楼市
       二手房行情
       租赁行情
       商品住宅日成交
       预售许可证
    重点房源推介
    政策法律
    全国人大
    国务院
       行政法规
       国发国办文件
    部委规章文件
       住建部规章
       住建部文件
       财政税务局
       其它部委及法院
    省级法规及文件
    市级文件
       市政府文件
       市级部门文件
    专题报道
       经验分享
       资料分享
       股票知识
       健康保健
    加盟八千家
       加盟八千家
       经纪人天地
   
   当前位置--八千家资讯--经验分享--正文

静态网页时间代码大全
    您访问8000j·宝鸡房地产网    录入:绿叶 时间:2018-1-2 9:55:40  点击数:1367    

一、实时走动的数字时钟 如:下午14:15:00

第一步:在<body></body>区域加入以下代码

XML/HTML代码
<script>  
function tick() {   
var hours, minutes, seconds, xfile;   
var intHours, intMinutes, intSeconds;   
var today;   
today = new Date();   
intHours = today.getHours();   
intMinutes = today.getMinutes();   
intSeconds = today.getSeconds();   
if (intHours == 0) {   
hours = "12:";   
xfile = "午夜";   
} else if (intHours < 12) {    
hours = intHours+":";   
xfile = "上午";   
} else if (intHours == 12) {   
hours = "12:";   
xfile = "正午";   
} else {   
intHoursintHours = intHours - 12   
hours = intHours + ":";   
xfile = "下午";   
  
if (intMinutes < 10) {   
minutes = "0"+intMinutes+":";   
} else {   
minutes = intMinutes+":";   
  
if (intSeconds < 10) {   
seconds = "0"+intSeconds+" ";   
} else {   
seconds = intSeconds+" ";   
   
timeString = xfile+hours+minutes+seconds;   
Clock.innerHTML = timeString;   
window.setTimeout("tick();", 100);   
  
window.onload = tick;   
</script>  

第二步.将下面的代码加入html文件任意需要的地方

<div id="Clock" align="center" style="font-size: 20; color:#000000"></div>

你可以自行更改样式!

二、显示年月日格式的时间代码 如:2008年11月27日 星期四

XML/HTML代码
<script language=javascript>  
today=new Date();   
function initArray(){   
this.length=initArray.arguments.length   
for(var i=0;i<this.length;i++)   
this[i+1]=initArray.arguments[i] }   
var d=new initArray(   
"星期日",   
"星期一",   
"星期二",   
"星期三",   
"星期四",   
"星期五",   
"星期六");   
document.write(   
"<font color=##000000 style='font-size:9pt;font-family: 宋体'> ",   
today.getYear(),"年",   
today.getMonth()+1,"月",   
today.getDate(),"日",   
d[today.getDay()+1],   
"</font>" );   
</script> 

三、显示日期,星期,时间格式的代码 如:2008年11月27日星期四 下午2:17:36

XML/HTML代码
<SCRIPT language=javascript>
 today=new Date();
 function initArray(){
   this.length=initArray.arguments.length
   for(var i=0;i<this.length;i++)
   this[i+1]=initArray.arguments[i]  }
   var d=new initArray(
     "星期日",
     "星期一",
     "星期二",
     "星期三",
     "星期四",
     "星期五",
     "星期六");
document.write(
     "<font color=#ecc1c1 style='font-size:9pt;font-family: 宋体'> ",
     today.getYear(),"年",
     today.getMonth()+1,"月",
     today.getDate(),"日",
     d[today.getDay()+1],
     "</font>" );
            </SCRIPT>
                </TD>
                <TD class=bai align=left width=95>
                  <SCRIPT language=javascript>
 
function tick() {
var hours, minutes, seconds, xfile;
var intHours, intMinutes, intSeconds;
var today;
today = new Date();
intHours = today.getHours();
intMinutes = today.getMinutes();
intSeconds = today.getSeconds();
if (intHours == 0) {
hours = "12:";
xfile = "午夜";
} else if (intHours < 12) {
hours = intHours+":";
xfile = "上午";
} else if (intHours == 12) {
hours = "12:";
xfile = "正午";
} else {
intHours = intHours - 12
hours = intHours + ":";
xfile = "下午";
}
if (intMinutes < 10) {
minutes = "0"+intMinutes+":";
} else {
minutes = intMinutes+":";
}
if (intSeconds < 10) {
seconds = "0"+intSeconds+" ";
} else {
seconds = intSeconds+" ";
}
timeString = xfile+hours+minutes+seconds;
Clock.innerHTML = timeString;
window.setTimeout("tick();", 100);
}
window.onload = tick;
</SCRIPT>
<DIV id=Clock style="FONT-SIZE: 12px; COLOR: #ecc1c1" align=center></DIV>

四、显示来访者的停留时间 如:停留时间: 00:15

XML/HTML代码
<script language="javascript">  
var ap_name = navigator.appName;   
var ap_vinfo = navigator.appVersion;   
var ap_ver = parseFloat(ap_vinfo.substring(0,ap_vinfo.indexOf('(')));   
  
var time_start = new Date();   
var clock_start = time_start.getTime();   
var dl_ok=false;   
  
function init ()   
  
if(ap_name=="Netscape" && ap_ver>=3.0)   
dl_ok=true;    
return true;   
  
  
function get_time_spent ()   
   
var time_now = new Date();   
return((time_now.getTime() - clock_start)/1000);    
  
  
function show_secs () // show the time user spent on the side   
   
var i_total_secs = Math.round(get_time_spent());    
var i_secs_spent = i_total_secs % 60;   
var i_mins_spent = Math.round((i_total_secs-30)/60);    
var s_secs_spent = "" + ((i_secs_spent>9) ? i_secs_spent : "0" + i_secs_spent);   
var s_mins_spent = "" + ((i_mins_spent>9) ? i_mins_spent : "0" + i_mins_spent);   
document.fm0.time_spent.value = s_mins_spent + ":" + s_secs_spent;   
window.setTimeout('show_secs()',1000);    
  
  
// -->  
</script>  
<FORM name="fm0" onSubmit="0"><FONT COLOR="#6060FF">停留时间:   
</FONT><INPUT type="text" name="time_spent" size=7 onFocus="this.blur()"></FORM>  
  
而且还要在你主页源文件<body>中加入下面的代码   
  
<BODY onLoad="init(); window.setTimeout('show_secs()',1);">  

五、显示当前日期与时间 如:现在是: 2008年11月27日 14:18:59 时间不走动

XML/HTML代码
<script language="javascript">  
<!--   
now = new Date()   
hour = now.getHours()   
if (hour < 12) {   
document.write("现在是: " + now.toLocaleString())   
} else if (hour < 18){   
document.write("现在是: " + now.toLocaleString())   
} else if (hour >= 18) {   
document.write("现在是: " + now.toLocaleString())   
  
// --></script>  

六、浏览器状态栏显示的时钟 如:2:20 P.M. 星期四 在状态栏显示

XML/HTML代码
<BODY onLoad="run(); timerONE=window.setTimeout"></BODY>  
<SCRIPT LANGUAGE="javascript">  
<!-- Hide   
timeID = null;   
timeRunning = false;   
function stop () {   
if(timeRunning)   
clearTimeout(timeID);   
timeRunning = false;   
  
function time () {   
tick = new Date();   
hours = tick.getHours();   
minutes = tick.getMinutes();   
seconds = tick.getSeconds();   
day = tick.getDay();   
month = tick.getMonth();   
date = tick.getDate();   
year = tick.getYear();   
current = "" + ((hours >12) ? hours -12 :hours)   
current += ((minutes < 10) ? ":0" : ":") + minutes   
current += ((seconds < 10) ? ":0" : ":") + seconds   
current += (hours >= 12) ? " P.M." : " A.M."   
if(day==0){var weekday = " 星期日"}   
if(day==1){var weekday = " 星期一"}   
if(day==2){var weekday = " 星期二"}   
if(day==3){var weekday = " 星期三"}   
if(day==4){var weekday = " 星期四"}   
if(day==5){var weekday = " 星期五"}   
if(day==6){var weekday = " 星期六"}   
current +=(weekday)   
window.status=current;   
timeID = setTimeout("time()",1000);   
timeRunning = true;   
  
function run(){   
stop();   
time();   
  
  
//-->  
</SCRIPT>  

七、显示最后更新时间代码 如:最后更新时间: 11/27/2008 14:21:04

XML/HTML代码
<SCRIPT language=javascript>  
<!--hide script from old browsers   
document.write("最后更新时间: " + document.lastModified + "")   
// end hiding -->  
</SCRIPT>  

八、实时走动的数字时钟 如:下午14:22:03

XML/HTML代码
<script>  
function tick() {   
var hours, minutes, seconds, xfile;   
var intHours, intMinutes, intSeconds;   
var today;   
today = new Date();   
intHours = today.getHours();   
intMinutes = today.getMinutes();   
intSeconds = today.getSeconds();   
if (intHours == 0) {   
hours = "12:";   
xfile = "午夜";   
} else if (intHours < 12) {    
hours = intHours+":";   
xfile = "上午";   
} else if (intHours == 12) {   
hours = "12:";   
xfile = "正午";   
} else {   
intHoursintHours = intHours - 12   
hours = intHours + ":";   
xfile = "下午";   
  
if (intMinutes < 10) {   
minutes = "0"+intMinutes+":";   
} else {   
minutes = intMinutes+":";   
  
if (intSeconds < 10) {   
seconds = "0"+intSeconds+" ";   
} else {   
seconds = intSeconds+" ";   
   
timeString = xfile+hours+minutes+seconds;   
Clock.innerHTML = timeString;   
window.setTimeout("tick();", 100);   
  
window.onload = tick;   
</script>  
  
<div id="Clock" style="font-size: 20; color:#000000"></div>  

九、根据不同的时间显示不同的问候语 如:午安!

XML/HTML代码
方法:在主页中你需要的地方加入以下代码:   
  
<script language="LiveScript">  
now = new Date(),hour = now.getHours()   
if(hour < 6){document.write("明天不用上班了吗?")}   
else if (hour < 8){document.write("全新的一天!")}   
else if (hour < 12){document.write("早安!")}   
else if (hour < 14){document.write("外面太阳大吗?")}   
else if (hour < 18){document.write("午安!")}   
else if (hour < 22){document.write("晚上好!")}   
else if (hour < 24){document.write("夜深了! 要注意身体呀! 祝你做个好梦!")}   
// -->  
</script>  
  
说明,可以自行修改出更好更多的问候语!  

十、显示年月日星期及农历的月和日 如:2008年11月27日 星期四 农历 10月30日

第一步:将一下代码保存为.JS文件

XML/HTML代码
<!--         
function CalConv()         
         
    FIRSTYEAR = 1998;         
    LASTYEAR = 2031;         
         
    today = new Date();         
    SolarYear = today.getFullYear();         
    SolarMonth = today.getMonth() + 1;         
    SolarDate = today.getDate();         
    Weekday = today.getDay();         
    LunarCal = [         
  new tagLunarCal( 27,  5, 3, 43, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1 ),         
  new tagLunarCal( 46,  0, 4, 48, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 ),          
  new tagLunarCal( 35,  0, 5, 53, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1 ),          
  new tagLunarCal( 23,  4, 0, 59, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),         
  new tagLunarCal( 42,  0, 1,  4, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),         
  new tagLunarCal( 31,  0, 2,  9, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0 ),         
  new tagLunarCal( 21,  2, 3, 14, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 ),          
  new tagLunarCal( 39,  0, 5, 20, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ),         
  new tagLunarCal( 28,  7, 6, 25, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1 ),         
  new tagLunarCal( 48,  0, 0, 30, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ),         
  new tagLunarCal( 37,  0, 1, 35, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1 ),          
  new tagLunarCal( 25,  5, 3, 41, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ),         
  new tagLunarCal( 44,  0, 4, 46, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ),         
  new tagLunarCal( 33,  0, 5, 51, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),         
  new tagLunarCal( 22,  4, 6, 56, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ),          
  new tagLunarCal( 40,  0, 1,  2, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ),         
  new tagLunarCal( 30,  9, 2,  7, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ),         
  new tagLunarCal( 49,  0, 3, 12, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1 ),         
  new tagLunarCal( 38,  0, 4, 17, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0 ),          
  new tagLunarCal( 27,  6, 6, 23, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1 ),         
  new tagLunarCal( 46,  0, 0, 28, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0 ),         
  new tagLunarCal( 35,  0, 1, 33, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ),         
  new tagLunarCal( 24,  4, 2, 38, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),          
  new tagLunarCal( 42,  0, 4, 44, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ),         
  new tagLunarCal( 31,  0, 5, 49, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0 ),         
  new tagLunarCal( 21,  2, 6, 54, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ),         
  new tagLunarCal( 40,  0, 0, 59, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ),          
  new tagLunarCal( 28,  6, 2,  5, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0 ),         
  new tagLunarCal( 47,  0, 3, 10, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1 ),         
  new tagLunarCal( 36,  0, 4, 15, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1 ),         
  new tagLunarCal( 25,  5, 5, 20, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ),          
  new tagLunarCal( 43,  0, 0, 26, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ),         
  new tagLunarCal( 32,  0, 1, 31, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0 ),         
  new tagLunarCal( 22,  3, 2, 36, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0 ) ];         
          
 SolarCal = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];         
         
           
SolarDays = [  0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396,  0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366, 397 ];         
    AnimalIdx = ["马", "羊", "猴", "鸡", "狗", "猪", "鼠", "牛", "虎", "兔", "龙", "蛇" ];         
    LocationIdx = [ "南", "东", "北", "西" ];         
    if ( SolarYear <= FIRSTYEAR || SolarYear > LASTYEAR ) return 1;         
    sm = SolarMonth - 1;         
        if ( sm < 0 || sm > 11 ) return 2;         
        leap = GetLeap( SolarYear );         
    if ( sm == 1 )         
        d = leap + 28;         
    else         
        d = SolarCal[sm];         
    if ( SolarDate < 1 || SolarDate > d ) return 3;         
    y = SolarYear - FIRSTYEAR;         
    acc = SolarDays[ leap*14 + sm ] + SolarDate;         
    kc = acc + LunarCal[y].BaseKanChih;         
    Kan = kc % 10;         
    Chih = kc % 12;         
    Location = LocationIdx[kc % 4];         
    Age = kc % 60;         
    if ( Age < 22 )         
        Age = 22 - Age;         
    else         
        Age = 82 - Age;         
    Animal = AnimalIdx[ Chih ];         
         
    if ( acc <= LunarCal[y].BaseDays ) {         
        y--;         
        LunarYear = SolarYear - 1;         
        leap = GetLeap( LunarYear );         
        sm += 12;         
        acc = SolarDays[leap*14 + sm] + SolarDate;         
             
    else         
        LunarYear = SolarYear;         
            l1 = LunarCal[y].BaseDays;         
    for ( i=0; i<13; i++ ) {         
        l2 = l1 + LunarCal[y].MonthDays[i] + 29;         
        if ( acc <= l2 ) break;         
        l1 = l2;         
             
    LunarMonth = i + 1;         
    LunarDate = acc - l1;         
    im = LunarCal[y].Intercalation;         
    if ( im != 0 && LunarMonth > im ) {         
        LunarMonth--;         
        if ( LunarMonth == im ) LunarMonth = -im;         
             
    if ( LunarMonth > 12 ) LunarMonth -= 12;         
 today=new Date();         
        function initArray(){         
                         this.length=initArray.arguments.length         
                         for(var i=0;i<this.length;i++)         
                         this[i+1]=initArray.arguments[i]          
       var d=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六");         
             document.write("<span class=\"jsdhtml\"> ", today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日 ",d[today.getDay()+1],"");         
      document.write( "<span class=\"jsdhtml\"> 农历 " + LunarMonth + "月" + LunarDate + "日");         
         
                                  return 0;          
        
          
function GetLeap( year )         
         
   if ( year % 400 == 0 )         
     return 1;         
   else if ( year % 100 == 0 )         
     return 0;         
   else if ( year % 4 == 0 )         
     return 1;         
   else         
     return 0;         
         
function tagLunarCal( d, i, w, k, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13) {         
 this.BaseDays = d;                  
 this.Intercalation = i;             
 this.BaseWeekday = w;               
 this.BaseKanChih = k;               
 this.MonthDays = [ m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13 ];          
        
//-->         
         
CalConv();  

第二步:在你网页所需要的地方插入调用代码

XML/HTML代码
<script language=javascript src="刚才命名.js"></script>  

十一、根据不同的时候显示不同的问候+后面跟着一句不变的话 如:下午好! ……

XML/HTML代码
<SCRIPT language=javascript><!--   
     var welcomestring;   
     var mydate = new Date();   
     var myyear = mydate.getYear();   
     if(myyear < 300)myyear = 1900 + myyear ;   
     mymonth = mydate.getMonth()+1;   
     today = mydate.getDate();   
     myhour = mydate.getHours();   
     if(myhour<6)   
     welcomestring="凌晨好";   
     else if(myhour<9)   
     welcomestring="早上好";   
     else if(myhour<12)   
     welcomestring="上午好";   
     else if(myhour<14)   
     welcomestring="中午好";   
     else if(myhour<17)   
     welcomestring="下午好";   
     else if(myhour<19)   
     welcomestring="傍晚好";   
     else if(myhour<22)   
     welcomestring="晚上好";   
     else   
     welcomestring="夜里好";   
     document.writeln(welcomestring+ "!欢迎访问公安县夹竹园镇北湖渔场网站 ");   
     //-->  
     </SCRIPT>  

十二、显示年月日星期及今年的第几周 如:2008年11月27日 星期四 今年的第44周

XML/HTML代码
<script language=javascript>  
  function weekOfYear(year, month, day){   
  var date1 = new Date(year, 0, 1);   
  var date2 = new Date(year, month-1, day, 1);   
  var dayMS = 24*60*60*1000;   
  var firstDay = (7-date1.getDay())*dayMS;   
  var weekMS = 7*dayMS;   
  date1date1 = date1.getTime();   
  date2date2 = date2.getTime();   
  return Math.ceil((date2-date1-firstDay)/weekMS)+1;   
    
  
today=new Date();   
function initArray(){   
this.length=initArray.arguments.length;   
for(var i=0;i<this.length;i++)   
this[i+1]=initArray.arguments[i]   
  
var d=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六");   
document.write("<font style='font-size:9pt;font-family: 宋体'>",today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日 ",d[today.getDay()+1]," 今年的第",weekOfYear(today.getYear(),today.getMonth(),today.getDate()),"周","</font>");   
</script>  

十三、显示年月日、农历月日及星期 如:2008年11月27日 农历十月三十 星期四

XML/HTML代码
<script type="text/javascript">var now=new Date();</script>  
  
<script language=javascript>  
var lunarinfo=new Array(0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x055d2,   
0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x14977,   
0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x04970,   
0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950,   
0x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4,0x025d0,0x092d0,0x0d2b2,0x0a950,0x0b557,   
0x06ca0,0x0b550,0x15355,0x04da0,0x0a5d0,0x14573,0x052d0,0x0a9a8,0x0e950,0x06aa0,   
0x0aea6,0x0ab50,0x04b60,0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0,   
0x096d0,0x04dd5,0x04ad0,0x0a4d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b5a0,0x195a6,   
0x095b0,0x049b0,0x0a974,0x0a4b0,0x0b27a,0x06a50,0x06d40,0x0af46,0x0ab60,0x09570,   
0x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0x0ab60,0x096d5,0x092e0,   
0x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0x0abb7,0x025d0,0x092d0,0x0cab5,   
0x0a950,0x0b4a0,0x0baa4,0x0ad50,0x055d9,0x04ba0,0x0a5b0,0x15176,0x052b0,0x0a930,   
0x07954,0x06aa0,0x0ad50,0x05b52,0x04b60,0x0a6e6,0x0a4e0,0x0d260,0x0ea65,0x0d530,   
0x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,0x0a4d0,0x1d0b6,0x0d250,0x0d520,0x0dd45,   
0x0b5a0,0x056d0,0x055b2,0x049b0,0x0a577,0x0a4b0,0x0aa50,0x1b255,0x06d20,0x0ada0);   
var animals=new Array("鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪");   
var gan=new Array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸");   
var zhi=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");   
//var now = new Date(2008,3,27);   
var sy = now.getFullYear();    
var sm = now.getMonth();   
var sd = now.getDate();   
var xq = now.getDay();   
//==== 传入 offset 传回干支, 0=甲子   
function cyclical(num) { return(gan[num]+zhi[num])}   
//==== 传回农历 y年的总天数   
function lyeardays(y) {   
var i, sum = 348  
for(i=0x8000; i>0x8; i>>=1) sum += (lunarinfo[y-1900] & i)? 1: 0   
return(sum+leapdays(y))   
  
//==== 传回农历 y年闰月的天数   
function leapdays(y) {   
if(leapmonth(y)) return((lunarinfo[y-1900] & 0x10000)? 30: 29)   
else return(0)   
  
//==== 传回农历 y年闰哪个月 1-12 , 没闰传回 0   
function leapmonth(y) { return(lunarinfo[y-1900] & 0xf)}   
//====================================== 传回农历 y年m月的总天数   
function monthdays(y,m) { return( (lunarinfo[y-1900] & (0x10000>>m))? 30: 29 )}   
//==== 算出农历, 传入日期物件, 传回农历日期物件   
// 该物件属性有 .year .month .day .isleap .yearcyl .daycyl .moncyl   
function lunar(objdate) {   
var i, leap=0, temp=0  
var basedate = new Date(1900,0,31)   
var offset = (objdate - basedate)/86400000   
this.daycyl = offset + 40   
this.moncyl = 14  
for(i=1900; i<2050 && offset>0; i++) {   
temp = lyeardays(i)   
offset -= temp  
this.moncyl += 12   
  
if(offset<0) {   
offset += temp;   
i--;   
this.moncyl -= 12  
  
this.year = i   
this.yearcyl = i-1864   
leap = leapmonth(i) //闰哪个月   
this.isleap = false  
for(i=1; i<13 && offset>0; i++) {   
//闰月   
if(leap>0 && i==(leap+1) && this.isleap==false)   
{ --i; this.isleap = true; temp = leapdays(this.year); }   
else   
{ temp = monthdays(this.year, i); }   
//解除闰月   
if(this.isleap==true && i==(leap+1)) this.isleap = false  
offset -= temp  
if(this.isleap == false) this.moncyl ++   
  
if(offset==0 && leap>0 && i==leap+1)   
if(this.isleap)   
{ this.isleap = false; }   
else   
{ this.isleap = true; --i; --this.moncyl;}   
if(offset<0){ offset += temp; --i; --this.moncyl; }   
this.month = i   
this.day = offset + 1   
  
 function yymmdd(){    
var cl = '<font color="#ff0000" style="font-size:9pt;">';   
if (now.getday() == 0) cl = '<font color="#c00000" style="font-size:9pt;">';    
if (now.getday() == 6) cl = '<font color="#00c000" style="font-size:9pt;">';   
return(cl+sy+'年'+(sm+1)+'月'+sd+'日</font>');    
   
 function weekday(){    
myArray = new Array(6);   
myArray[0] = "星期日"   
myArray[1] = "星期一"   
myArray[2] = "星期二"   
myArray[3] = "星期三"   
myArray[4] = "星期四"   
myArray[5] = "星期五"   
myArray[6] = "星期六"   
weekday = now.getDay();   
document.write(myArray[weekday])   
  
function cday(m,d){   
 var nstr1 = new Array('日','一','二','三','四','五','六','七','八','九','十');   
 var nstr2 = new Array('初','十','廿','卅',' ');   
 var s;   
 if (m>10){s = '十'+nstr1[m-10]} else {s = nstr1[m]} s += '月'   
 if (s=="十二月") s = "腊月";   
 if (s=="一月") s = "正月";   
 switch (d) {   
case 10:s += '初十'; break;   
case 20:s += '二十'; break;   
case 30:s += '三十'; break;   
default:s += nstr2[Math.floor(d/10)]; s += nstr1[d];   
   
 return(s);   
  
 function solarday1(){   
var sdobj = new Date(sy,sm,sd);   
var ldobj = new lunar(sdobj);   
var cl = '<font color="violet" style="font-size:9pt;">';    
var tt = '【'+animals[(sy-4)]+'】'+cyclical(ldobj.moncyl)+'月 '+cyclical(ldobj.daycyl++)+'日' ;   
document.write(cl+tt+'</font>');   
   
 function solarday2(){   
var sdobj = new Date(sy,sm,sd);   
var ldobj = new lunar(sdobj);   
var cl = '';    
//农历bb'+(cld[d].isleap?'闰 ':' ')+cld[d].lmonth+' 月 '+cld[d].lday+' 日   
var tt = cday(ldobj.month,ldobj.day);   
document.write('农历'+tt+'');   
   
 function solarday3(){   
var sterminfo = new Array(0,21208,42467,63836,85337,107014,128867,150921,173149,195551,218072,240693,263343,285989,308563,331033,353350,375494,397447,419210,440795,462224,483532,504758)   
var solarterm = new Array("小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至")   
var lftv = new Array("0101*春节","0115 元宵节","0505 端午节","0707 七夕情人节","0715 中元节","0815 中秋节","0909 重阳节","1208 腊八节","1224 小年","0100*除夕")   
var sftv = new Array("0101*元旦","0214 情人节","0308 妇女节","0309 偶今天又长一岁拉","0312 植树节","0315 消费者权益日","0401 愚人节","0418 mm的生日","0501 劳动节","0504 青年节","0512 护士节","0601 儿童节","0701 建党节 香港回归纪念",   
"0801 建军节","0808 父亲节","0909 毛泽东逝世纪念","0910 教师节","0928 孔子诞辰","1001*国庆节",   
"1006 老人节","1024 联合国日","1112 孙中山诞辰","1220 澳门回归纪念","1225 圣诞节","1226 毛泽东诞辰")   
var sdobj = new Date(sy,sm,sd);   
var ldobj = new lunar(sdobj);   
var ldpos = new Array(3);   
var festival='',solarterms='',solarfestival='',lunarfestival='',tmp1,tmp2;   
//农历节日    
for(i in lftv)   
if(lftv[i].match(/^(\d{2})(.{2})([\s\*])(.+)$/)) {   
tmp1=number(regexp.$1)-ldobj.month   
tmp2=number(regexp.$2)-ldobj.day   
if(tmp1==0 && tmp2==0) lunarfestival=regexp.$4    
  
//国历节日   
for(i in sftv)   
if(sftv[i].match(/^(\d{2})(\d{2})([\s\*])(.+)$/)){   
tmp1=number(regexp.$1)-(sm+1)   
tmp2=number(regexp.$2)-sd   
if(tmp1==0 && tmp2==0) solarfestival = regexp.$4    
  
//节气   
tmp1 = new date((31556925974.7*(sy-1900)+sterminfo[sm*2+1]*60000)+date.utc(1900,0,6,2,5))   
tmp2 = tmp1.getutcdate()   
if (tmp2==sd) solartermsolarterms = solarterm[sm*2+1]    
tmp1 = new date((31556925974.7*(sy-1900)+sterminfo[sm*2]*60000)+date.utc(1900,0,6,2,5))   
tmp2= tmp1.getutcdate()   
if (tmp2==sd) solartermsolarterms = solarterm[sm*2]    
if(solarterms == '' && solarfestival == '' && lunarfestival == '')   
festival = '';   
else   
festival = '<table width=100% border=0 cellpadding=2 cellspacing=0 bgcolor="#ccffcc"><tr><td>'+   
'<font color="#000000" style="font-size:9pt;">'+solarterms + ' ' + solarfestival + ' ' + lunarfestival+'</font></td>'+   
'</tr></table>';   
var cl = '<font color="#000066" style="font-size:9pt;">';   
//document.write(cl+festival+'</font>');   
alert(cl+festival);   
   
 function setcalendar(){   
document.write('<table align=center cellpadding=2 cellspacing=0 border=1><tr><td bgcolor=#fefeef><table border=0 cellpadding=0 cellspacing=0><tr><td align=center>');   
document.write(yymmdd()+'  '+weekday());   
document.write('</td></tr>');   
document.write('<tr><td align=center>');    
document.write(solarday1());   
document.write('</td></tr><tr><td align=center>');    
document.write(solarday2());   
document.write('</td></tr><tr><td>');   
document.write(solarday3());   
document.write('</td></tr></table></td></tr></table>');   
   
</script>  
  
<script type="text/javascript">document.write(now.getFullYear()+"年"+(now.getMonth()+1)+"月"+now.getDate()+"日");</script> <script language="javascript" type="text/javascript">solarday2();</script> <script language="javascript" type="text/javascript">weekday();</script>  

十四、显示大写的年月日 如:二○○八年十一月二十一日

XML/HTML代码
<SCRIPT LANGUAGE="javascript">  
<!--   
document.write((new Date()).getYear().toString().replace(/1/gi,"一").replace(/2/gi,"二").replace(/3/gi,"三").replace(/4/gi,"四").replace(/5/gi,"五").replace(/6/gi,"六").replace(/7/gi,"七").replace(/8/gi,"八").replace(/9/gi,"九").replace(/0/gi,"○")+"年");   
document.write(("一,二,三,四,五,六,七,八,九,十,十一,十二".split(","))[(new Date()).getMonth()]+"月");   
document.write(("一,二,三,四,五,六,七,八,九,十,十一,十二,十三,十四,十五,十六,十七,十八,十九,二十,二十一,二十二,二十三,二十四,二十五,二十六,二十七,二十八,二十九,三十,三十一".split(","))[(new Date()).getDate()-1]+"日 ");   
//-->  
</SCRIPT>  

十五、显示年月日、时间及星期 如:2008年11月22日 10:10:58  星期六

XML/HTML代码
<script language="javascript" type="text/javascript">  
function setTime()   
  
var dt=new Date();   
var arr_week=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");   
var week=arr_week[dt.getDay()];   
time.innerHTML=dt.toLocaleString()+"  "+week;   
  
setInterval("setTime()",1000);   
</script>  
<div id="time"></div>  

十六、显示年月日、星期及农历XX年 XX月XX日  如:2008年11月27日 星期四 农历戊子年 十月三十

XML/HTML代码
<SCRIPT language=javascript >
function RunGLNL(){
var today=new Date();
var d=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
var DDDD=(today.getYear()<100 ? today.getYear()+1900:today.getYear())+"年"+(today.getMonth()+1)+"月"+today.getDate()+"日";
DDDD = DDDD + " " + d[today.getDay()];
DDDD = DDDD+ "&nbsp;&nbsp;&nbsp;" + (CnDateofDateStr(today));
//DDDD = DDDD+ " " + SolarTerm(today);
document.write(DDDD);
}
function DaysNumberofDate(DateGL){
return parseInt((Date.parse(DateGL)-Date.parse(DateGL.getYear()+"/1/1"))/86400000)+1;
}
function CnDateofDate(DateGL){
var CnData=new Array(
0x16,0x2a,0xda,0x00,0x83,0x49,0xb6,0x05,0x0e,0x64,0xbb,0x00,0x19,0xb2,0x5b,0x00,
0x87,0x6a,0x57,0x04,0x12,0x75,0x2b,0x00,0x1d,0xb6,0x95,0x00,0x8a,0xad,0x55,0x02,
0x15,0x55,0xaa,0x00,0x82,0x55,0x6c,0x07,0x0d,0xc9,0x76,0x00,0x17,0x64,0xb7,0x00,
0x86,0xe4,0xae,0x05,0x11,0xea,0x56,0x00,0x1b,0x6d,0x2a,0x00,0x88,0x5a,0xaa,0x04,
0x14,0xad,0x55,0x00,0x81,0xaa,0xd5,0x09,0x0b,0x52,0xea,0x00,0x16,0xa9,0x6d,0x00,
0x84,0xa9,0x5d,0x06,0x0f,0xd4,0xae,0x00,0x1a,0xea,0x4d,0x00,0x87,0xba,0x55,0x04
);
var CnMonth=new Array();
var CnMonthDays=new Array();
var CnBeginDay;
var LeapMonth;
var Bytes=new Array();
var I;
var CnMonthData;
var DaysCount;
var CnDaysCount;
var ResultMonth;
var ResultDay;
var yyyy=DateGL.getYear();
var mm=DateGL.getMonth()+1;
var dd=DateGL.getDate();
if(yyyy<100) yyyy+=1900;
  if ((yyyy < 1997) || (yyyy > 2020)){
    return 0;
    }
  Bytes[0] = CnData[(yyyy - 1997) * 4];
  Bytes[1] = CnData[(yyyy - 1997) * 4 + 1];
  Bytes[2] = CnData[(yyyy - 1997) * 4 + 2];
  Bytes[3] = CnData[(yyyy - 1997) * 4 + 3];
  if ((Bytes[0] & 0x80) != 0) {CnMonth[0] = 12;}
  else {CnMonth[0] = 11;}
  CnBeginDay = (Bytes[0] & 0x7f);
  CnMonthData = Bytes[1];
  CnMonthData = CnMonthData << 8;
  CnMonthData = CnMonthData | Bytes[2];
  LeapMonth = Bytes[3];
for (I=15;I>=0;I--){
    CnMonthDays[15 - I] = 29;
    if (((1 << I) & CnMonthData) != 0 ){
      CnMonthDays[15 - I]++;}
    if (CnMonth[15 - I] == LeapMonth ){
      CnMonth[15 - I + 1] = - LeapMonth;}
    else{
      if (CnMonth[15 - I] < 0 ){CnMonth[15 - I + 1] = - CnMonth[15 - I] + 1;}
      else {CnMonth[15 - I + 1] = CnMonth[15 - I] + 1;}
      if (CnMonth[15 - I + 1] > 12 ){ CnMonth[15 - I + 1] = 1;}
    }
  }
  DaysCount = DaysNumberofDate(DateGL) - 1;
  if (DaysCount <= (CnMonthDays[0] - CnBeginDay)){
    if ((yyyy > 1901) && (CnDateofDate(new Date((yyyy - 1)+"/12/31")) < 0)){
      ResultMonth = - CnMonth[0];}
    else {ResultMonth = CnMonth[0];}
    ResultDay = CnBeginDay + DaysCount;
  }
  else{
    CnDaysCount = CnMonthDays[0] - CnBeginDay;
    I = 1;
    while ((CnDaysCount < DaysCount) && (CnDaysCount + CnMonthDays[I] < DaysCount)){
      CnDaysCount+= CnMonthDays[I];
      I++;
    }
    ResultMonth = CnMonth[I];
    ResultDay = DaysCount - CnDaysCount;
  }
  if (ResultMonth > 0){
    return ResultMonth * 100 + ResultDay;}
  else{return ResultMonth * 100 - ResultDay;}
}
function CnYearofDate(DateGL){
var YYYY=DateGL.getYear();
var MM=DateGL.getMonth()+1;
var CnMM=parseInt(Math.abs(CnDateofDate(DateGL))/100);
if(YYYY<100) YYYY+=1900;
if(CnMM>MM) YYYY--;
YYYY-=1864;
return CnEra(YYYY)+"年";
}
function CnMonthofDate(DateGL){
var  CnMonthStr=new Array("零","正","二","三","四","五","六","七","八","九","十","十一","十二");
var  Month;
  Month = parseInt(CnDateofDate(DateGL)/100);
  if (Month < 0){return "闰" + CnMonthStr[-Month] + "月";}
  else{return CnMonthStr[Month] + "月";}
}
function CnDayofDate(DateGL){
var CnDayStr=new Array("零",
    "初一", "初二", "初三", "初四", "初五",
    "初六", "初七", "初八", "初九", "初十",
    "十一", "十二", "十三", "十四", "十五",
    "十六", "十七", "十八", "十九", "二十",
    "廿一", "廿二", "廿三", "廿四", "廿五",
    "廿六", "廿七", "廿八", "廿九", "三十");
var Day;
  Day = (Math.abs(CnDateofDate(DateGL)))0;
  return CnDayStr[Day];
}
function DaysNumberofMonth(DateGL){
var MM1=DateGL.getYear();
    MM1<100 ? MM1+=1900:MM1;
var MM2=MM1;
    MM1+="/"+(DateGL.getMonth()+1);
    MM2+="/"+(DateGL.getMonth()+2);
    MM1+="/1";
    MM2+="/1";
return parseInt((Date.parse(MM2)-Date.parse(MM1))/86400000);
}
function CnEra(YYYY){
var Tiangan=new Array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸");
//var Dizhi=new Array("子(鼠)","丑(牛)","寅(虎)","卯(兔)","辰(龙)","巳(蛇)",
                    //"午(马)","未(羊)","申(猴)","酉(鸡)","戌(狗)","亥(猪)");
var Dizhi=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");
return Tiangan[YYYY]+Dizhi[YYYY];
}
function CnDateofDateStr(DateGL){
  if(CnMonthofDate(DateGL)=="零月") return " 请调整您的计算机日期!";
  else return "农历"+CnYearofDate(DateGL)+ " " + CnMonthofDate(DateGL) + CnDayofDate(DateGL);
}
function SolarTerm(DateGL){
  var SolarTermStr=new Array(
        "小寒","大寒","立春","雨水","惊蛰","春分",
        "清明","谷雨","立夏","小满","芒种","夏至",
        "小暑","大暑","立秋","处暑","白露","秋分",
        "寒露","霜降","立冬","小雪","大雪","冬至");
  var DifferenceInMonth=new Array(
        1272060,1275495,1281180,1289445,1299225,1310355,
        1321560,1333035,1342770,1350855,1356420,1359045,
        1358580,1355055,1348695,1340040,1329630,1318455,
        1306935,1297380,1286865,1277730,1274550,1271556);
  var DifferenceInYear=31556926;
  var BeginTime=new Date(1901/1/1);
  BeginTime.setTime(947120460000);
     for(;DateGL.getYear()<BeginTime.getYear();){
        BeginTime.setTime(BeginTime.getTime()-DifferenceInYear*1000);
     }
     for(;DateGL.getYear()>BeginTime.getYear();){
        BeginTime.setTime(BeginTime.getTime()+DifferenceInYear*1000);
     }
     for(var M=0;DateGL.getMonth()>BeginTime.getMonth();M++){
        BeginTime.setTime(BeginTime.getTime()+DifferenceInMonth[M]*1000);
     }
     if(DateGL.getDate()>BeginTime.getDate()){
        BeginTime.setTime(BeginTime.getTime()+DifferenceInMonth[M]*1000);
        M++;
     }
     if(DateGL.getDate()>BeginTime.getDate()){
        BeginTime.setTime(BeginTime.getTime()+DifferenceInMonth[M]*1000);
        M==23?M=0:M++;
     }
  var JQ;
  if(DateGL.getDate()==BeginTime.getDate()){
    JQ="  今天是<font color='#FF9999'><b>"+SolarTermStr[M] + "</b></font>";
  }
  else if(DateGL.getDate()==BeginTime.getDate()-1){
    JQ="  明天是<font color='#FF9999'><b>"+SolarTermStr[M] + "</b></font>";
  }
  else if(DateGL.getDate()==BeginTime.getDate()-2){
    JQ="  后天是<font color='#FF9999'><b>"+SolarTermStr[M] + "</b></font>";
  }
  else{
    JQ=" "
   if(DateGL.getMonth()==BeginTime.getMonth()){
      JQ+="  本月";
   }
   else{
     JQ+="  下月";
   }
   JQ+=BeginTime.getDate()+"日"+"<font color='#FF9999'><b>"+SolarTermStr[M]+"</b></font>";
  }
return JQ;
}
function CAL()
{}
RunGLNL();
function CurentTime(){
    var now = new Date();
    var hh = now.getHours();
    var mm = now.getMinutes();
    var ss = now.getTime() % 60000;
    ss = (ss - (ss % 1000)) / 1000;
    var clock = hh+':';
    if (mm < 10) clock += '0';
    clock += mm+':';
    if (ss < 10) clock += '0';
    clock += ss;
    return(clock);
}
</SCRIPT>
十七、显示年月日、星期及当前实时走动的时间  如:2008年12月02日 星期二 15:50:50

先将以下代码保存为 time.js 

XML/HTML代码
var dayarray=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六")   
var montharray=new Array("01","02","03","04","05","06","07","08","09","10","11","12")   
function getthedate(){   
var mydate=new Date()   
var year=mydate.getYear()   
if (year < 1000)   
year+=1900   
var day=mydate.getDay()   
var month=mydate.getMonth()   
var daym=mydate.getDate()   
if (daym<10)   
daym="0"+daym   
var hours=mydate.getHours()   
var minutes=mydate.getMinutes()   
var seconds=mydate.getSeconds()   
//var dn="上午"  
//if (hours>=12)   
//dn="下午"  
//if (hours>12){   
//hourshours=hours-12   
//}   
//if (hours==0)   
//hours=12  
var dn=""  
if (minutes<=9)   
minutes="0"+minutes   
if (seconds<=9)   
seconds="0"+seconds   
//change font size here   
var cdate=" "+year+"年"+montharray[month]+"月"+daym+"日"+" "+dayarray[day]+" "+dn+" "+hours+":"+minutes+":"+seconds   
if (document.all)   
document.all.clock.innerHTML=cdate  
else   
document.write(cdate)   
  
if (!document.all)   
getthedate()   
function goforit(){   
if (document.all)   
setInterval("getthedate()",1000)   
  
goforit();   
  
document.write("<span id=clock></span>");  

 再在网页显示处插入以下调用代码:

XML/HTML代码
<script src="time.js" type="text/javascript"></script>  

十八、只显示农历日期  如:农历三月(小)十八

XML/HTML代码
<SCRIPT type=text/javascript>
  var dateInfo=solarDay3();
  var nl=new Lunar(new Date());
  var monthAndDAY=cDay(nl.month,Math.floor(nl.day));
  var monthType="";
  var days=0;
  if(nl.isLeap)
   days=leapDays(nl.year);
  else
   days=monthDays(nl.year,nl.month);
  if(days<30)
   monthType='小';
  else
   monthType='大';
  if(nl.isLeap)
   monthType+=' 闰';
    </SCRIPT>
<SCRIPT>
document.write("农历"+monthAndDAY.month+"月("+monthType+")"+monthAndDAY.day+" <span class=\"yellow\">"+dateInfo.jieqi+"</span></li>");
</SCRIPT>
十九、只显示生肖年及农历日期  如:己丑年 四月十七

先将下面的代码保存为:data.js

XML/HTML代码
<!--
   var CalendarData=new Array(100);var madd=new Array(12);var tgString="甲乙丙丁戊己庚辛壬癸";var dzString="子丑寅卯辰巳午未申酉戌亥";var numString="一二三四五六七八九十";var monString="正二三四五六七八九十冬腊";var weekString="日一二三四五六";var sx="鼠牛虎兔龙蛇马羊猴鸡狗猪";var cYear,cMonth,cDay,TheDate;
CalendarData = new Array(              0xA4B,0x5164B,0x6A5,0x6D4,0x415B5,0x2B6,0x957,0x2092F,0x497,0x60C96,                    0xD4A,0xEA5,0x50DA9,0x5AD,0x2B6,0x3126E, 0x92E,0x7192D,0xC95,0xD4A,                      0x61B4A,0xB55,0x56A,0x4155B, 0x25D,0x92D,0x2192B,0xA95,0x71695,0x6CA,                  0xB55,0x50AB5,0x4DA,0xA5B,0x30A57,0x52B,0x8152A,0xE95,0x6AA,0x615AA,                    0xAB5,0x4B6,0x414AE,0xA57,0x526,0x31D26,0xD95,0x70B55,0x56A,0x96D,                   0x5095D,0x4AD,0xA4D,0x41A4D,0xD25,0x81AA5, 0xB54,0xB6A,0x612DA,0x95B,
0x49B,0x41497,0xA4B,0xA164B, 0x6A5,0x6D4,0x615B4,0xAB6,0x957,0x5092F,
0x497,0x64B, 0x30D4A,0xEA5,0x80D65,0x5AC,0xAB6,0x5126D,0x92E,0xC96,                  0x41A95,0xD4A,0xDA5,0x20B55,0x56A,0x7155B,0x25D,0x92D,0x5192B,0xA95,                  0xB4A,0x416AA,0xAD5,0x90AB5,0x4BA,0xA5B, 0x60A57,0x52B,0xA93,0x40E95);
madd[0]=0;madd[1]=31;madd[2]=59;madd[3]=90;
madd[4]=120;madd[5]=151;madd[6]=181;madd[7]=212;
madd[8]=243;madd[9]=273;madd[10]=304;madd[11]=334;
 
function GetBit(m,n) {  return (m>>n)&1; }
function e2c()

TheDate= (arguments.length!=3) ? new Date() : new Date(arguments[0],arguments[1],arguments[2]); 
var total,m,n,k; 
var isEnd=false; 
var tmp=TheDate.getFullYear(); 
 total=(tmp-1921)*365+Math.floor((tmp-1921)/4)+madd[TheDate.getMonth()]+TheDate.getDate()-38;  if (TheDate.getYear()%4==0&&TheDate.getMonth()>1) { total++;}  for(m=0;;m++)     k=(CalendarData[m]<0xfff)?11:12;    for(n=k;n>=0;n--)         if(total<=29+GetBit(CalendarData[m],n))             isEnd=true; break;           total=total-29-GetBit(CalendarData[m],n);       if(isEnd) break;   cYear=1921 + m; cMonth=k-n+1; cDay=total;  if(k==12)     if(cMonth==Math.floor(CalendarData[m]/0x10000)+1) { cMonth=1-cMonth; }   if(cMonth>Math.floor(CalendarData[m]/0x10000)+1)  { cMonth--; }   }}
function GetcDateString(){ var tmp="";  tmp+=tgString.charAt((cYear-4));
tmp+=dzString.charAt((cYear-4)); 
tmp+="年 ";
if(cMonth<1) { tmp+="(闰)"; tmp+=monString.charAt(-cMonth-1); } else {tmp+=monString.charAt(cMonth-1);}  tmp+="月";  tmp+=(cDay<11)?"初":((cDay<20)?"十":((cDay<30)?"廿":"三十"));
if (cDay!=0||cDay==10) { tmp+=numString.charAt((cDay-1)); }  return tmp;}
function GetLunarDay(solarYear,solarMonth,solarDay)
{
 if (solarYear<1921 || solarYear>2020)           return "";
         else                 solarMonth = (parseInt(solarMonth)>0) ? (solarMonth-1) : 11;          e2c(solarYear,solarMonth,solarDay); return GetcDateString();        }}
var D=new Date();
var yy=D.getFullYear();
var mm=D.getMonth()+1;
var dd=D.getDate();
var ww=D.getDay();
var ss=parseInt(D.getTime() / 1000);
 
function CAL(){
 
document.write("<table border='0' cellspacing='0' cellpadding='0'");
document.write("<tr><td align='center'  class='b12'><span class='b12'>"+GetLunarDay(yy,mm,dd));
document.write("</span></td></tr></table>");
}
-->

 然后在网页所需要显示的地方加入如下代码调用:

XML/HTML代码
<script language="javascript" type="text/javascript" src="data.js"></script><script language="javascript" type="text/javascript">CAL();</script>

 

  • 上一篇文章: EXCEL中如何让某些行列固定不动

  • 下一篇文章: 静态网页时间代码大全
  • 发表评论打印此文】【关闭窗口
      网友评论:(评论内容只代表网友观点,与本站立场无关!)
        没有任何评论


    Copyright @2005 All Rights Reserved
    版权所有:8000j网(八千家)
    声明:本网站文章、数据来源于网络,仅供学习之用,不构成投资建议,如有侵权,电函后3日内删除。
    电话:0917-15309175008 E-mail:8000j@163.com
    八千里路云和月,让爱有个家!——八千家(8000j)