求一个HTML5日期时间控件。

求一个HTML5日期时间控件。,第1张

<input type="date">这就会自带日期控件了。。。

HTML5 拥有多个供选择日期和时间的新的输入类型:

date - 选择日、月、年

month - 选择月、年

week - 选择周、年

time - 选择时间(时、分)

datetime - 选择时间、日期、月、年(UTC 时间)

datetime-local - 选择时间、日期、月、年(本地时间)

你可以试试不同类型出来的效果,,

如果想要更好看的,那只能去搞个jquery的日期控件来用了,毕竟做得比较成熟,,

但是个人还是很喜欢html5这个新属性,,一句短短的就搞定了,,

不过有一个不好处就是,不同的浏览器渲染出来的效果有些差别。。。。

去下载个My97Date 日历控件用法:下载后解压缩,把My97DatePicker文件夹拷贝到网站目录然后在html页的<head>标签内引入WdatePicker.js.如下:<script language="javascript" type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>其中src=""里面的为你的WdatePicker.js文件所在路径最后,给需要插入日期的文本框添加onClick属性:onClick="WdatePicker()";例如:<input type=text onClick="WdatePicker()">OK,就这么简单

<script language="javascript" type="text/javascript">

var enabled = 0today = new Date()

var dayvar date

if(today.getDay()==0) day = "星期日 "

if(today.getDay()==1) day = "星期一 "

if(today.getDay()==2) day = "星期二 "

if(today.getDay()==3) day = "星期三 "

if(today.getDay()==4) day = "星期四 "

if(today.getDay()==5) day = "星期五 "

if(today.getDay()==6) day = "星期六 "

document.fgColor = " FF0072"

date1 =(today.getMonth() + 1 ) + "月" + today.getDate() + "日 "

date2 = day

document.write(date1.fontsize(2))

document.write(date2.fontsize(2))

document.write("<span id='clock'></span>")

var now,hours,minutes,seconds,timeValue

function showtime(){

now = new Date()

hours = now.getHours()

minutes = now.getMinutes()

seconds = now.getSeconds()

timeValue = (hours >= 12) ? " " : " "

timeValue += hours+ ":"

timeValue += ((minutes <10) ? "0" : "") + minutes + ":"


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/7140726.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-02
下一篇2023-04-02

发表评论

登录后才能评论

评论列表(0条)

    保存