- 浏览: 105467 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
wanmeinange:
不错。。真的存 date要存string
mysql 数据截断异常 -
shengqishiwu:
跑不起来,能让浏览器死掉的代码
javascript 无弹出式表单验证 -
queen_love:
难到LS的仍进洗衣机里洗过 ...
纪念一下 -
娴静女生:
还好,你没仍进洗衣机里洗一把,已经很幸运了,
敢情是 ...
纪念一下 -
king_108:
上PP,才好評價
纪念一下
1.创建日历控件的javascript ---(在下面)
2.引入我们要用的日历空间
<script type="text/javascript" src="/GMS/js/sd.js"></script>
3.日历控件的使用实例
<input type="text" name="sdrq" id="sdrq" value="" style="width:7em" onclick="popUpCalendar(sdrq,sdrq,'yyyy-mm-dd')" readonly/>
sd.js
var fixedX = -1
var fixedY = -1
var startAt = 1
var showWeekNumber = 0
var showToday = 0
var gotoString = "转到当前月:"
var todayString = "今天是:"
var weekString = "星期"
var scrollLeftMessage = "上一个月。 按住连续向前。"
var scrollRightMessage = "下一个月。按住连续向后"
var selectMonthMessage = "选择月份。"
var selectYearMessage = "选择年份。"
var selectDateMessage = "选择:[date]"
var crossobj, crossMonthObj, crossYearObj, monthSelected, yearSelected, dateSelected, omonthSelected, oyearSelected, odateSelected, monthConstructed,
yearConstructed, intervalID1, intervalID2, timeoutID1, timeoutID2, ctlToPlaceValue, ctlNow, dateFormat, nStartingYear, nStartingMonth
var bPageLoaded=false
var ie = false;
var dom=document.getElementById
var ns4=document.layers
var today = new Date()
var dateNow = today.getDate()
var monthNow = today.getMonth()
var yearNow = today.getYear()
var bShow = false;
if((navigator.userAgent.toLowerCase().indexOf("opera") == -1) && (navigator.userAgent.toLowerCase().indexOf("msie") != -1))
{
ie = true;
}
function hideElement( elmID, overDiv )
{
if( ie )
{
for( i = 0; i < document.all.tags( elmID ).length; i++ )
{
obj = document.all.tags( elmID )[i];
if( !obj || !obj.offsetParent )
{
continue;
}
objLeft = obj.offsetLeft;
objTop = obj.offsetTop;
objParent = obj.offsetParent;
while( objParent.tagName.toUpperCase() != "BODY" )
{
objLeft += objParent.offsetLeft;
objTop += objParent.offsetTop;
objParent = objParent.offsetParent;
}
objHeight = obj.offsetHeight;
objWidth = obj.offsetWidth;
if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
else if( overDiv.offsetTop >= ( objTop + objHeight ));
else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
else
{
obj.style.visibility = "hidden";
}
}
}
}
function showElement( elmID )
{
if( ie )
{
for( i = 0; i < document.all.tags( elmID ).length; i++ )
{
obj = document.all.tags( elmID )[i];
if( !obj || !obj.offsetParent )
{
continue;
}
obj.style.visibility = "";
}
}
}
function HolidayRec (d, m, y, desc)
{
this.d = d
this.m = m
this.y = y
this.desc = desc
}
var HolidaysCounter = 0
var Holidays = new Array()
function addHoliday (d, m, y, desc)
{
Holidays[HolidaysCounter++] = new HolidayRec ( d, m, y, desc )
}
if (dom)
{
document.write ("<div onclick='bShow=true' id='calendar' style='z-index:+999;position:absolute;visibility:hidden;'><table width="+((showWeekNumber==1)?250:220)+"
style='border-width:1;border-style:solid;border-color:#666666' bgcolor='#ffffff'><tr bgcolor='#666666'><td><table width='"+((showWeekNumber==1)?248:218)+"'><tr><td
style='padding:2px;'><font color='#ffffff'><B><span id='caption'></span></B></font></td><td align=right><span style='color:#FFFFFF;cursor:pointer'
onclick='javascript:hideCalendar()'><b>×</b></span></td></tr></table></td></tr><tr><td style='padding:5px' bgcolor=#ffffff><span id='content'></span></td></tr>")
if (showToday==1)
{
document.write ("<tr bgcolor=#f0f0f0><td style='padding:5px' align=center><span id='lblToday'></span></td></tr>")
}
document.write ("</table></div><div id='selectMonth' style='z-index:+999;position:absolute;visibility:hidden;'></div><div id='selectYear' style='z-
index:+999;position:absolute;visibility:hidden;'></div>");
}
var monthName = new Array("01","02","03","04","05","06","07","08","09","10","11","12")
var monthName2 = new Array("01","02","03","04","05","06","07","08","09","10","11","12")
if (startAt==0)
{
dayName = new Array ("日","一","二","三","四","五","六")
}
else
{
dayName = new Array ("一","二","三","四","五","六","日")
}
var styleAnchor="text-decoration:none;color:black;"
var styleLightBorder="border-style:solid;border-width:1px;border-color:#666666;"
function init() {
if (!ns4)
{
if (!ie) { yearNow += 1900 }
crossobj=(dom)?document.getElementById("calendar").style : ie? document.all.calendar : document.calendar
hideCalendar()
crossMonthObj=(dom)?document.getElementById("selectMonth").style : ie? document.all.selectMonth : document.selectMonth
crossYearObj=(dom)?document.getElementById("selectYear").style : ie? document.all.selectYear : document.selectYear
monthConstructed=false;
yearConstructed=false;
if (showToday==1)
{
document.getElementById("lblToday").innerHTML = todayString + " <a onmousemove='window.status=\""+gotoString+"\"' onmouseout='window.status=\"\"'
title='"+gotoString+"' style='"+styleAnchor+"' href='javascript:monthSelected=monthNow;yearSelected=yearNow;constructCalendar();'>"+dayName[(today.getDay()-startAt==-1)?6:
(today.getDay()-startAt)]+", " + dateNow + " " + monthName[monthNow].substring(0,3) + " " + yearNow + "</a>"
}
sHTML1="<span id='spanLeft' title='上一月' style='border-style:solid;border-width:1;border-color:#999999;cursor:pointer'
onmouseover='window.status=\""+scrollLeftMessage+"\"' onclick='javascript:decMonth()' onmouseout='clearInterval(intervalID1);window.status=\"\"' onmousedown='clearTimeout
(timeoutID1);timeoutID1=setTimeout(\"StartDecMonth()\",500)' onmouseup='clearTimeout(timeoutID1);clearInterval(intervalID1)'> ← </span> "
sHTML1+="<span id='spanYear' style='border-style:solid;border-width:1;border-color:#999999;cursor:pointer'
onmouseover='window.status=\""+selectYearMessage+"\"' onmouseout='window.status=\"\"' onclick='popUpYear()'></span> "
sHTML1+="<span id='spanMonth' style='border-style:solid;border-width:1;border-color:#999999;cursor:pointer'
onmouseover='window.status=\""+selectMonthMessage+"\"' onmouseout='window.status=\"\"' onclick='popUpMonth()'></span> "
sHTML1+="<span id='spanRight' title='下一月' style='border-style:solid;border-width:1;border-color:#999999;cursor:pointer'
onmouseover='window.status=\""+scrollRightMessage+"\"' onmouseout='clearInterval(intervalID1);window.status=\"\"' onclick='incMonth()' onmousedown='clearTimeout
(timeoutID1);timeoutID1=setTimeout(\"StartIncMonth()\",500)' onmouseup='clearTimeout(timeoutID1);clearInterval(intervalID1)'> → </span> "
/** Chrislee modify by 2008-02-28 add clean text -- start **/
sHTML1+="<span id='clearText' style='border-style:solid;border-width:1;border-color:#999999;cursor:pointer' onclick='cleanText()'>清空</span> "
/** Chrislee modify by 2008-02-28 add clean text -- end **/
document.getElementById("caption").innerHTML = sHTML1
bPageLoaded=true
}
}
/** Chrislee modify by 2008-02-28 add clean text -- start **/
function cleanText(){
hideCalendar();
ctlToPlaceValue.value = "";
}
/** Chrislee modify by 2008-02-28 add clean text -- start **/
function hideCalendar() {
crossobj.visibility="hidden"
if (crossMonthObj != null){crossMonthObj.visibility="hidden"}
if (crossYearObj != null){crossYearObj.visibility="hidden"}
showElement( 'SELECT' );
showElement( 'APPLET' );
}
function padZero(num) {
return (num < 10)? '0' + num : num ;
}
function constructDate(d,m,y)
{
sTmp = dateFormat
sTmp = sTmp.replace ("dd","<e>")
sTmp = sTmp.replace ("d","<d>")
sTmp = sTmp.replace ("<e>",d)
sTmp = sTmp.replace ("<d>",d)
sTmp = sTmp.replace ("mmmm","<p>")
sTmp = sTmp.replace ("mmm","<o>")
sTmp = sTmp.replace ("mm","<n>")
sTmp = sTmp.replace ("m","<m>")
sTmp = sTmp.replace ("<m>",m+1)
sTmp = sTmp.replace ("<n>",m+1)
sTmp = sTmp.replace ("<o>",monthName[m])
sTmp = sTmp.replace ("<p>",monthName2[m])
sTmp = sTmp.replace ("yyyy",y)
return sTmp.replace ("yy",padZero(y%100))
}
function closeCalendar() {
var sTmp
hideCalendar();
ctlToPlaceValue.value = constructDate(dateSelected,monthSelected,yearSelected)
}
function StartDecMonth()
{
intervalID1=setInterval("decMonth()",80)
}
function StartIncMonth()
{
intervalID1=setInterval("incMonth()",80)
}
function incMonth () {
monthSelected++
if (monthSelected>11) {
monthSelected=0
yearSelected++
}
constructCalendar()
}
function decMonth () {
monthSelected--
if (monthSelected<0) {
monthSelected=11
yearSelected--
}
constructCalendar()
}
function upMonth() {
if(nStartingMonth > 0)
{
nStartingMonth --;
for (i=0; i<6; i++)
{
newMonth = (i + nStartingMonth);
if (newMonth == monthSelected)
txtMonth = " <B>" + monthName[newMonth] + "</B> ";
else
txtMonth = " " + monthName[newMonth] + " ";
document.getElementById("m"+i).innerHTML = txtMonth;
}
}
bShow=true
}
function downMonth() {
if(nStartingMonth < 6)
{
nStartingMonth ++;
for (i=0; i<6; i++)
{
newMonth = (i + nStartingMonth);
if (newMonth == monthSelected)
txtMonth = " <B>" + monthName[newMonth] + "</B> ";
else
txtMonth = " " + monthName[newMonth] + " ";
document.getElementById("m"+i).innerHTML = txtMonth;
}
}
bShow=true
}
function selectMonth(nMonth) {
monthSelected=parseInt(nMonth+nStartingMonth);
monthConstructed=false;
constructCalendar();
popDownMonth();
}
function constructMonth() {
popDownYear()
if (!monthConstructed) {
sHTML = "<tr><td align='center' onmouseover='this.style.backgroundColor=\"#FFCC99\"' onmouseout='clearInterval
(intervalID1);this.style.backgroundColor=\"\"' style='cursor:pointer' onmousedown='clearInterval(intervalID1);intervalID1=setInterval(\"upMonth()\",30)'
onmouseup='clearInterval(intervalID1)'>-</td></tr>"
j=0;
i=(monthSelected-3);
if(i < 0)
i=0;
if(i > 6)
i=6;
nStartingMonth = i;
for (ii=0; ii<6; ii++, i++, j++) {
sName = monthName[i];
if (i==monthSelected){
sName = "<B>" + sName + "</B>"
}
sHTML += "<tr><td id='m" + j + "' onmouseover='this.style.backgroundColor=\"#FFCC99\"' onmouseout='this.style.backgroundColor=\"\"'
style='cursor:pointer' onclick='selectMonth(" + j + ");event.cancelBubble=true'> " + sName + " </td></tr>"
}
sHTML += "<tr><td align='center' onmouseover='this.style.backgroundColor=\"#FFCC99\"' onmouseout='clearInterval
(intervalID2);this.style.backgroundColor=\"\"' style='cursor:pointer' onmousedown='clearInterval(intervalID2);intervalID2=setInterval(\"downMonth()\",30)'
onmouseup='clearInterval(intervalID2)'>+</td></tr>"
document.getElementById("selectMonth").innerHTML = "<table width=32 style='border-width:1; border-style:solid; border-color:#a0a0a0;'
bgcolor='#FFFFDD' cellspacing=0 onmouseover='clearTimeout(timeoutID1)' onmouseout='clearTimeout(timeoutID1);timeoutID1=setTimeout(\"popDownMonth()
\",100);event.cancelBubble=true'>" + sHTML + "</table>"
monthConstructed=true
}
}
function popUpMonth() {
constructMonth()
crossMonthObj.visibility = (dom||ie)? "visible" : "show"
crossMonthObj.left = parseInt(crossobj.left) + 90
crossMonthObj.top = parseInt(crossobj.top) + 26
hideElement( 'SELECT', document.getElementById("selectMonth") );
hideElement( 'APPLET', document.getElementById("selectMonth") );
}
function popDownMonth() {
crossMonthObj.visibility= "hidden"
}
function incYear() {
for (i=0; i<6; i++){
newYear = (i+nStartingYear)+1
if (newYear==yearSelected)
{ txtYear = " <B>" + newYear + "</B> " }
else
{ txtYear = " " + newYear + " " }
document.getElementById("y"+i).innerHTML = txtYear
}
nStartingYear ++;
bShow=true
}
function decYear() {
for (i=0; i<6; i++){
newYear = (i+nStartingYear)-1
if (newYear==yearSelected)
{ txtYear = " <B>" + newYear + "</B> " }
else
{ txtYear = " " + newYear + " " }
document.getElementById("y"+i).innerHTML = txtYear
}
nStartingYear --;
bShow=true
}
function selectYear(nYear) {
yearSelected=parseInt(nYear+nStartingYear);
yearConstructed=false;
constructCalendar();
popDownYear();
}
function constructYear() {
popDownMonth()
sHTML = ""
if (!yearConstructed) {
sHTML = "<tr><td align='center' onmouseover='this.style.backgroundColor=\"#FFCC99\"' onmouseout='clearInterval
(intervalID1);this.style.backgroundColor=\"\"' style='cursor:pointer' onmousedown='clearInterval(intervalID1);intervalID1=setInterval(\"decYear()\",30)'
onmouseup='clearInterval(intervalID1)'>-</td></tr>"
j = 0
nStartingYear = yearSelected-3
for (i=(yearSelected-3); i<(yearSelected+3); i++) {
sName = i;
if (i==yearSelected){
sName = "<B>" + sName + "</B>"
}
sHTML += "<tr><td id='y" + j + "' onmouseover='this.style.backgroundColor=\"#FFCC99\"' onmouseout='this.style.backgroundColor=\"\"'
style='cursor:pointer' onclick='selectYear("+j+");event.cancelBubble=true'> " + sName + " </td></tr>"
j ++;
}
sHTML += "<tr><td align='center' onmouseover='this.style.backgroundColor=\"#FFCC99\"' onmouseout='clearInterval
(intervalID2);this.style.backgroundColor=\"\"' style='cursor:pointer' onmousedown='clearInterval(intervalID2);intervalID2=setInterval(\"incYear()\",30)'
onmouseup='clearInterval(intervalID2)'>+</td></tr>"
document.getElementById("selectYear").innerHTML = "<table width=44 style='font-family:arial; font-size:11px; border-width:1; border-style:solid; border-
color:#a0a0a0;' bgcolor='#FFFFDD' onmouseover='clearTimeout(timeoutID2)' onmouseout='clearTimeout(timeoutID2);timeoutID2=setTimeout(\"popDownYear()\",100)' cellspacing=0>" +
sHTML + "</table>"
yearConstructed = true
}
}
function popDownYear() {
clearInterval(intervalID1)
clearTimeout(timeoutID1)
clearInterval(intervalID2)
clearTimeout(timeoutID2)
crossYearObj.visibility= "hidden"
}
function popUpYear() {
var leftOffset
constructYear()
crossYearObj.visibility = (dom||ie)? "visible" : "show"
leftOffset = parseInt(crossobj.left) + document.getElementById("spanYear").offsetLeft
if (ie)
{
leftOffset += 10
}
crossYearObj.left = leftOffset
crossYearObj.top = parseInt(crossobj.top) + 26
}
function WeekNbr(n) {
year = n.getFullYear();
month = n.getMonth() + 1;
if (startAt == 0) {
day = n.getDate() + 1;
}
else {
day = n.getDate();
}
a = Math.floor((14-month) / 12);
y = year + 4800 - a;
m = month + 12 * a - 3;
b = Math.floor(y/4) - Math.floor(y/100) + Math.floor(y/400);
J = day + Math.floor((153 * m + 2) / 5) + 365 * y + b - 32045;
d4 = (((J + 31741 - (J % 7)) % 146097) % 36524) % 1461;
L = Math.floor(d4 / 1460);
d1 = ((d4 - L) % 365) + L;
week = Math.floor(d1/7) + 1;
return week;
}
function constructCalendar () {
var aNumDays = Array (31,0,31,30,31,30,31,31,30,31,30,31)
var dateMessage
var startDate = new Date (yearSelected,monthSelected,1)
var endDate
if (monthSelected==1)
{
endDate = new Date (yearSelected,monthSelected+1,1);
endDate = new Date (endDate - (24*60*60*1000));
numDaysInMonth = endDate.getDate()
}
else
{
numDaysInMonth = aNumDays[monthSelected];
}
datePointer = 0
dayPointer = startDate.getDay() - startAt
if (dayPointer<0)
{
dayPointer = 6
}
sHTML = "<table border=0 style='font-family:verdana;font-size:10pt;'><tr>"
if (showWeekNumber==1)
{
sHTML += "<td width=27><b>" + weekString + "</b></td>"
}
for (i=0; i<7; i++) {
sHTML += "<td width='27' style='font-size:11pt;' align='right'><B>"+ dayName[i]+"</B></td>"
}
sHTML +="</tr><tr>"
if (showWeekNumber==1)
{
sHTML += "<td align=right>" + WeekNbr(startDate) + " </td>"
}
for ( var i=1; i<=dayPointer;i++ )
{
sHTML += "<td> </td>"
}
for ( datePointer=1; datePointer<=numDaysInMonth; datePointer++ )
{
dayPointer++;
sHTML += "<td align=right>"
sStyle=styleAnchor
if ((datePointer==odateSelected) && (monthSelected==omonthSelected) && (yearSelected==oyearSelected))
{ sStyle+=styleLightBorder }
sHint = ""
for (k=0;k<HolidaysCounter;k++)
{
if ((parseInt(Holidays[k].d)==datePointer)&&(parseInt(Holidays[k].m)==(monthSelected+1)))
{
if ((parseInt(Holidays[k].y)==0)||((parseInt(Holidays[k].y)==yearSelected)&&(parseInt(Holidays[k].y)!=0)))
{
sStyle+="background-color:#FFDDDD;"
sHint+=sHint==""?Holidays[k].desc:"\n"+Holidays[k].desc
}
}
}
var regexp= /\"/g
sHint=sHint.replace(regexp,""")
dateMessage = "onmousemove='window.status=\""+selectDateMessage.replace("[date]",constructDate(datePointer,monthSelected,yearSelected))+"\"'
onmouseout='window.status=\"\"' "
if ((datePointer==dateNow)&&(monthSelected==monthNow)&&(yearSelected==yearNow))
{ sHTML += "<b><a "+dateMessage+" title=\"" + sHint + "\" style='"+sStyle+"' href='javascript:dateSelected="+datePointer+";closeCalendar();'><font
color=#ff0000> " + datePointer + "</font> </a></b>"}
else if (dayPointer % 7 == (startAt * -1)+1)
{ sHTML += "<a "+dateMessage+" title=\"" + sHint + "\" style='"+sStyle+"' href='javascript:dateSelected="+datePointer + ";closeCalendar();'> <font
color=#909090>" + datePointer + "</font> </a>" }
else
{ sHTML += "<a "+dateMessage+" title=\"" + sHint + "\" style='"+sStyle+"' href='javascript:dateSelected="+datePointer + ";closeCalendar();'> " +
datePointer + " </a>" }
sHTML += ""
if ((dayPointer+startAt) % 7 == startAt) {
sHTML += "</tr><tr>"
if ((showWeekNumber==1)&&(datePointer<numDaysInMonth))
{
sHTML += "<td align=right>" + (WeekNbr(new Date(yearSelected,monthSelected,datePointer+1))) + " </td>"
}
}
}
document.getElementById("content").innerHTML = sHTML
document.getElementById("spanMonth").innerHTML = " " + monthName[monthSelected] + " ˇ"
document.getElementById("spanYear").innerHTML = " " + yearSelected + " ˇ"
}
/**
* ctl: 事件触发点
* ctl2: 表单域
*/
function popUpCalendar(ctl, ctl2, format) {
var leftpos=0
var toppos=0
if (bPageLoaded)
{
if ( crossobj.visibility == "hidden" ) {
ctlToPlaceValue = ctl2
dateFormat=format;
formatChar = " "
aFormat = dateFormat.split(formatChar)
if (aFormat.length<3)
{
formatChar = "/"
aFormat = dateFormat.split(formatChar)
if (aFormat.length<3)
{
formatChar = "."
aFormat = dateFormat.split(formatChar)
if (aFormat.length<3)
{
formatChar = "-"
aFormat = dateFormat.split(formatChar)
if (aFormat.length<3)
{
// invalid date format
formatChar=""
}
}
}
}
tokensChanged = 0
if ( formatChar != "" )
{
// use user's date
aData = ctl2.value.split(formatChar)
for (i=0;i<3;i++)
{
if ((aFormat[i]=="d") || (aFormat[i]=="dd"))
{
dateSelected = parseInt(aData[i], 10)
tokensChanged ++
}
else if ((aFormat[i]=="m") || (aFormat[i]=="mm"))
{
monthSelected = parseInt(aData[i], 10) - 1
tokensChanged ++
}
else if (aFormat[i]=="yyyy")
{
yearSelected = parseInt(aData[i], 10)
tokensChanged ++
}
else if (aFormat[i]=="mmm")
{
for (j=0; j<12; j++)
{
if (aData[i]==monthName[j])
{
monthSelected=j
tokensChanged ++
}
}
}
else if (aFormat[i]=="mmmm")
{
for (j=0; j<12; j++)
{
if (aData[i]==monthName2[j])
{
monthSelected=j
tokensChanged ++
}
}
}
}
}
if ((tokensChanged!=3)||isNaN(dateSelected)||isNaN(monthSelected)||isNaN(yearSelected))
{
dateSelected = dateNow
monthSelected = monthNow
yearSelected = yearNow
}
odateSelected=dateSelected
omonthSelected=monthSelected
oyearSelected=yearSelected
aTag = ctl
do {
aTag = aTag.offsetParent;
leftpos += aTag.offsetLeft;
toppos += aTag.offsetTop;
} while(aTag.tagName!="BODY");
crossobj.left = fixedX==-1 ? ctl.offsetLeft + leftpos : fixedX
crossobj.top = fixedY==-1 ? ctl.offsetTop + toppos + ctl.offsetHeight + 2 : fixedY
constructCalendar (1, monthSelected, yearSelected);
crossobj.visibility=(dom||ie)? "visible" : "show"
hideElement( 'SELECT', document.getElementById("calendar") );
hideElement( 'APPLET', document.getElementById("calendar") );
bShow = true;
}
else
{
hideCalendar()
if (ctlNow!=ctl) {popUpCalendar(ctl, ctl2, format)}
}
ctlNow = ctl
}
}
/*document.onkeypress = function hidecal1 () {
if (event.keyCode==27)
{
hideCalendar()
}
}*/
document.onclick = function hidecal2 () {
if (!bShow)
{
hideCalendar()
}
bShow = false
}
if(ie)
{
init()
}
else
{
window.onload=init
}
5.当向数据库中(mysql)插入一个日历控件格式的日期时,需要转换一下,当我们设定数据库的类型为datetime时
for Example:
/*获取到yrsr*/
String sdrq = request.getParameter("sdrq");
/*截取生日的年,月,日,然后在组合成数据库相应的格式*/
String[] yrsrSplit = sdrq.split("-");
String year = yrsrSplit[0];
String month = yrsrSplit[1];
String day = yrsrSplit[2];
/*像2008-4-6就得改成2008-04-06的格式*/
if(month.length()==1){
if(day.length()==1){
sdrq = year + "-0" + month + "-0" + day;
}
/*像2008-4-10只需改成2008-04-10*/
if(day.length()==2){
sdrq = year + "-0" + month + "-" + day;
}
}
if(month.length()==2){
if(day.length()==1){
sdrq = year + "-" + month + "-0" + day;
}
/*像2008-4-10只需改成2008-04-10*/
if(day.length()==2){
sdrq = year + "-" + month + "-" + day;
}
}
相关推荐
本案例中,我们讨论的是如何创建一个"winform自定义日历控件",模仿百度的日历展示样式。这个自定义控件通常会包含日期选择、事件标记、颜色定制等功能,以提供更加友好和个性化的用户体验。 在C#中,我们可以继承`...
本篇文章将深入探讨六个ASP.NET 日历控件的使用实例,帮助开发者更好地理解和应用这个功能。 1. **基础日历显示** - 创建一个简单的ASP.NET Web表单,添加Calendar 控件到页面。 - 配置控件属性,如TitleFormat、...
在给定的信息中,"My97DatePicker"是一个具体的日历控件实例,它可能是一个JavaScript库或.NET组件,用于在网页上添加交互式的日期选择功能。My97DatePicker以其高效、灵活和易用性而闻名,开发者可以方便地集成到...
VC++日历控件的使用不仅限于简单的日期选择,其灵活的配置选项和强大的自定义能力使其成为各种桌面应用中不可或缺的组件。无论是基本的日程管理软件,还是复杂的数据分析平台,合理利用日历控件都能显著提升用户体验...
在网页设计中,这种交互式的日历控件常用于预订系统、事件安排或者任何需要用户输入特定日期的场景。 首先,我们来深入了解一下HTML(超文本标记语言),它是构建网页的基础语言。在HTML页面中,我们可以添加各种...
在Qt框架中,日历控件是一个非常实用的组件,尤其对于开发需要日期选择功能的应用程序来说。本实例中,我们将深入探讨如何在Qt中使用日历控件,以实现一个能够显示万年历并允许用户查看具体日期的小程序。 首先,让...
在这个"js日历控件实例源码"中,我们有两个关键文件:`demo.html`和`setday.js`。 首先,`demo.html`是示例页面,它包含了控件的展示和交互界面。在HTML文件中,我们可以看到一个用于显示日历的占位符元素,通常是...
在本文中,我们将深入探讨如何在Qt环境中创建一个自定义的日历控件,特别是通过“Qt之自绘制日历控件(三)”的实例来学习。这个控件不仅完全自绘,而且具备了月份切换和记录当前选中日期的功能,这使得它在实际应用中...
"实用梅花雨日历控件实例"提供了一个美观的日历组件,适用于网页应用程序,帮助用户更直观地选择日期,提升用户体验。这个控件是用JavaScript编程语言实现的,其中可能包含了CSS样式和HTML结构,使得日历展示既功能...
- `main.qml`:应用程序的入口点,可能包含日历控件实例。 - `Calendar.qml`:自定义的日历组件实现。 - `styles/`:可能包含不同主题的样式文件。 - `examples/`:示例应用,演示如何使用日历控件。 - `tests/`:...
在IT开发领域,日历控件是经常被用于构建用户界面的一个重要元素,尤其是在需要用户输入日期或选择日期范围的应用中。"日历控件 附加源代码"的主题提供了使用日历控件的一个实例,这将帮助开发者更好地理解和实现...
在Android开发中,自定义日历控件是一个常见的需求,特别是在构建日程管理或时间规划类应用时。`mycalender`项目显然提供了一个自定义的日历视图,以满足开发者对日历显示和交互的个性化需求。下面将详细介绍自定义...
在本案例中,我们关注的是一个特别的日历控件,它以横向的方式显示日期,同时支持单击和双击事件。这个控件的实现可能涉及到自定义组件的设计和事件处理机制。 首先,"GlCalenderLevel.dpk" 是一个Delphi项目包文件...
在ASP.NET Web应用程序中,日历控件(Calendar ...通过学习这个实例,你可以熟练地在你的Web应用中集成日历控件,提供更直观、友好的日期选择功能。记住,实践是最好的老师,动手尝试并调整代码,以适应你的项目需求。
在wxPython中,`wx.lib.calendar.CalendarCtrl`是用于创建日历控件的类。这个控件提供了一个简洁的界面,用户可以点击特定日期来选择。首先,我们需要导入必要的模块,包括`wx`和`wx.lib.calendar`: ```python ...
JavaScript日历控件是网页应用中常见的一种交互元素,它允许用户方便地选择日期,常用于事件安排、预订系统或表单输入等场景。在这个英文版的JS日历控件中,开发者为英文操作系统的用户提供了友好的界面和功能。 ...
最后,对于压缩包中的“jquery_ui日历控件”文件,这可能包含了示例代码、样式文件或者已经配置好的日历控件实例,方便开发者快速集成到自己的项目中。为了使用这些资源,你需要将它们部署到服务器或本地开发环境中...
// 创建日历控件实例 ctlCalendar = new CMonthCalCtrl; } private: CMonthCalCtrl *ctlCalendar; }; BOOL CExercise1Dlg::OnInitDialog() { CDialog::OnInitDialog(); // 设置图标 SetIcon(m_hIcon, TRUE...
总之,"winform写的日历控件"是.NET WinForm开发中的一个实例,展示了如何结合C#编程语言和Windows Forms框架来创建具有特定功能的自定义控件。开发者需要掌握Windows Forms的基础知识,理解控件绘制原理,以及如何...
在软件开发中,日历控件是一个常用且实用的功能,它广泛应用于日程管理、时间选择等多种场景。本篇文章将深入探讨“日历控件”这一主题,通过分析源码和使用相关工具,为开发者提供更全面的理解和应用指南。 首先,...