html怎麼寫這個日歷

<!DOCTYPEhtml>
<htmllang="en">

<head>
<metacharset="UTF-8">
<title></title>
<style>
table{
width:230px;
margin:auto;
text-align:center;
border:1pxsoliddarkcyan;
border-bottom:3pxdoubledarkcyan;
box-shadow:01px2pxdarkcyan;
}

th,
td{
border:1pxsoliddarkcyan;
}

.today{
color:red;
}
</style>
<script>
//判斷當前年份是否是閏年(閏年2月份有29天,平年2月份只有28天)
functionisLeap(year){
returnyear%4==0?(year%100!=0?1:(year%400==0?1:0)):0;
}
vari,k,
today=newDate(),//獲取當前日期
y=today.getFullYear(),//獲取日期中的年份
m=today.getMonth(),//獲取日期中的月份(需要注意的是:月份是從0開始計算,獲取的值比正常月份的值少1)
d=today.getDate(),//獲取日期中的日(方便在建立日期表格時高亮顯示當天)
firstday=newDate(y,m,1),//獲取當月的第一天
dayOfWeek=firstday.getDay(),//判斷第一天是星期幾(返回[0-6]中的一個,0代表星期天,1代表星期一,以此類推)
days_per_month=newArray(31,28+isLeap(y),31,30,31,30,31,31,30,31,30,31),//創建月份數組
str_nums=Math.ceil((dayOfWeek+days_per_month[m])/7);//確定日期表格所需的行數
document.write("<tablecellspacing='0'><tr><tdcolspan='7'>"+y+"年"+(m+1)+"月"+"</td></tr>");
document.write("<tr><th>日</th><th>一</th><th>二</th><th>三</th><th>四</th><th>五</th><th>六</th></tr>");//列印表格第一行(顯示星期)
for(i=0;i<str_nums;i+=1){//二維數組創建日期表格
document.write('<tr>');
for(k=0;k<7;k++){
varidx=7*i+k;//為每個表格創建索引,從0開始
vardate=idx-dayOfWeek+1;//將當月的1號與星期進行匹配
(date<=0||date>days_per_month[m])?date='':date=idx-dayOfWeek+1;//索引小於等於0或者大於月份最大值就用空表格代替
date==d?document.write('<tdclass="today">'+date+'</td>'):document.write('<td>'+date+'</td>');//高亮顯示當天
}
document.write('</tr>');
}
document.write('</table>');
</script>
</head>

<body>
</body>

</html>

❷ html日期代碼

既然允許就可以運行,那代碼就沒問題的說

是不是你瀏覽器設置有限制,檢查一下吧

❸ 求時間日期html代碼,帶農歷!(高手進)

下面代碼可以實現你要的功能,如下。至於你看不到它的真實的源代碼,它可能通過程序動態載入,或者是js調用。你看到的,僅僅是靜態的html代碼而已!

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>單行帶農歷的日期時間代碼</title>
</head>

<body>
<SCRIPT language=javaScript>
<!--
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 ];

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;

Age = kc % 60;
if ( Age < 22 )
Age = 22 - Age;
else
Age = 82 - Age;

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("", today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日",d[today.getDay()+1],"");

months = ["一","二","三","四","五","六","七","八","九","十","十一","十二"];

days = ["初一","初二","初三","初四","初五","初六","初七","初八","初九","初十","十一","十二","十三","十四","十五","十六","十七","十八","十九","二十","廿一","廿二","廿三","廿四","廿五","廿六","廿七","廿八","廿九","三十"];

document.write( "農歷"+months[LunarMonth-1]+"月" + days[LunarDate-1] + "");

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 ];
}
//-->
</SCRIPT>
<a target=_blank href=http://www.qpsh.com><FONT color=#2b68a7><SCRIPT>CalConv();</SCRIPT></FONT></a>
</body>

</html>

❹ html中如何獲得當前日期

可以用javascript,先創建Date對象的實例(也叫做對象的引用)。創建實例的語法有如下三種。

varnewDateObj=newDate()
varnewDateObj=newDate(dateVal)
varnewDateObj=newDate(year,month,date[,hours[,minutes[,seconds[,ms]]]])

例如,var D = new Date()。

方法1,是無參數調用,創建後對象D中含有計算機的系統日期和時間。

方法2,dateVal參數是數值或表示日期時間的字元串。如果是數字值,dateVal 表示指定日期與 1970 年 1 月 1 日午夜間全球標准時間的毫秒數。如果是字元串,則 dateVal 按照 parse 方法中的規則進行解析。dateVal 參數也可以是從某些 ActiveX(R) 對象返回的 VT_DATE 值。

方法3,用參數直接為新建對象提供日期和時間的數據。

建立了Date對象以後,就可以使用get方法取得日期或時間的值,返回值一般是數值型的。用set方法給一個Date型對象設置數據。Date的方法函數的語法一般格式為:

D.getXXXX()和D.setXXXX(variablelist)

拓展資料:

HTML是一種規范,一種標准,它通過標記符號來標記要顯示的網頁中的各個部分。網頁文件本身是一種文本文件,通過在文本文件中添加標記符,可以告訴瀏覽器如何顯示其中的內容(如:文字如何處理,畫面如何安排,圖片如何顯示等)。

瀏覽器按順序閱讀網頁文件,然後根據標記符解釋和顯示其標記的內容,對書寫出錯的標記將不指出其錯誤,且不停止其解釋執行過程,編制者只能通過顯示效果來分析出錯原因和出錯部位。

但需要注意的是,對於不同的瀏覽器,對同一標記符可能會有不完全相同的解釋,因而可能會有不同的顯示效果。


❺ 求一個網頁日期顯示html代碼

哈~用JS!看這個!我這個簡單!下面還有時鍾~不要可以刪除
用js網頁會彈出一個阻止框!記得點允許~
<html>
<head>
<script type="text/javascript">
var d=new Date()//為日期命名
document.write("今天是:"+d.getFullYear()+"年")//返回年
document.write(d.getMonth()+"月")//返回月,月是從0-11的~所以顯示的是當前月份-1.若非要顯示當前月份!把這條刪了,換用這條語句:document.write((d.getMonth()+1)+"月")
document.write(d.getDate()+"日")//返回日

var weekday=new Array(7)//建立一個星期的數組
weekday[0]="星期日"
weekday[1]="星期一"
weekday[2]="星期二"
weekday[3]="星期三"
weekday[4]="星期四"
weekday[5]="星期五"
weekday[6]="星期六"

document.write(" " + weekday[d.getDay()])//輸出星期

function startTime()//以下為一個時鍾!附加的!不要可以刪除
{
var today=new Date()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
m=checkTime(m)
s=checkTime(s)
document.getElementById('txt').innerHTML=h+":"+m+":"+s
t=setTimeout('startTime()',500)
}

function checkTime(i)
{
if (i<10)
{i="0" + i}
return i
}
//上面的是時鍾
</script>
</head>

<body onload="startTime()">
<div id="txt"></div>
</body>
</html>

❻ 日期 時間 星期的html代碼是什麼代碼

1、雙擊打開MyEclipse IDE開發軟體,新建日期類DateUtils。

❼ 如何在html頁面中顯示日歷表

如果你用ASP.NET2.0在VS2005編程環境中只需要拖拽一個控制項即可搞定。
補充: 在HTML頁上我沒試過,多半是不行,因為ASP.NET的代碼運行需要.NET Franework。

希望回答對你有幫助,如果有疑問,請繼續追問
答題不易,互相理解,您的點贊是我前進的動力,感謝您。

❽ 如何用html寫代碼,使得在網頁上顯示當前的時間和日期

安裝如下步驟操作:

1.在電腦磁碟空白出右鍵-新建,點擊文檔

❾ html js當日日期顯示


//---------------------------------------------------
//日期格式化
//格式YYYY/yyyy/YY/yy表示年份
//MM/M月份
//W/w星期
//dd/DD/d/D日期
//hh/HH/h/H時間
//mm/m分鍾
//ss/SS/s/S秒
//---------------------------------------------------
Date.prototype.Format=function(formatStr)
{
varstr=formatStr;
varWeek=['日','一','二','三','四','五','六'];

str=str.replace(/yyyy|YYYY/,this.getFullYear());
str=str.replace(/yy|YY/,(this.getYear()%100)>9?(this.getYear()%100).toString():'0'+(this.getYear()%100));

str=str.replace(/MM/,this.getMonth()>9?this.getMonth().toString():'0'+this.getMonth());
str=str.replace(/M/g,this.getMonth());

str=str.replace(/w|W/g,Week[this.getDay()]);

str=str.replace(/dd|DD/,this.getDate()>9?this.getDate().toString():'0'+this.getDate());
str=str.replace(/d|D/g,this.getDate());

str=str.replace(/hh|HH/,this.getHours()>9?this.getHours().toString():'0'+this.getHours());
str=str.replace(/h|H/g,this.getHours());
str=str.replace(/mm/,this.getMinutes()>9?this.getMinutes().toString():'0'+this.getMinutes());
str=str.replace(/m/g,this.getMinutes());

str=str.replace(/ss|SS/,this.getSeconds()>9?this.getSeconds().toString():'0'+this.getSeconds());
str=str.replace(/s|S/g,this.getSeconds());

returnstr;
}

//當前時間
newDate().Format("yyyy-MM-dd");

你執行以下就知道了!