html网页代码中的时间样式怎么设置
<html><head><title>计算几天后的日期</title></head><body><center><fontcolor=redface="隶书"size=6...
<html>
<head>
<title>计算几天后的日期</title>
</head>
<body>
<center><font color=red face="隶书" size=6>提取当前日期</font></center>
<center>
<script language="JavaScript">
<!--
function AddDays(form) {
DaysToAdd=document.form.DaysToAdd.value;
var now=new Date();
var newdate=new Date();
var newtimems=newdate.getTime()+(DaysToAdd*24*60*60*1000);
newdate.setTime(newtimems);
document.form.display.value=newdate.toLocaleString();
}
-->
</script>
<SCRIPT LANGUAGE="JavaScript">
<!--
function goHist(a)
{
history.go(a);
}
-->
</script>
<form name=form>
<input type="hidden" type=text name=DaysToAdd size=4 value=0 onFocus="this.select()" onMouseOver="this.focus()">
<input type=text name="display" size=20 value="">
<input type=button value="提取当前时间" onClick="AddDays(this.form)" name="button">
</form>
</center>
</body>
</html>
提取的时间样式是:2015/6/23 下午6:12:51(这个不好看)
我想要的样式是:2015年06月23日 18:13:51
或者是:2015-06-23 18:13:51 展开
<head>
<title>计算几天后的日期</title>
</head>
<body>
<center><font color=red face="隶书" size=6>提取当前日期</font></center>
<center>
<script language="JavaScript">
<!--
function AddDays(form) {
DaysToAdd=document.form.DaysToAdd.value;
var now=new Date();
var newdate=new Date();
var newtimems=newdate.getTime()+(DaysToAdd*24*60*60*1000);
newdate.setTime(newtimems);
document.form.display.value=newdate.toLocaleString();
}
-->
</script>
<SCRIPT LANGUAGE="JavaScript">
<!--
function goHist(a)
{
history.go(a);
}
-->
</script>
<form name=form>
<input type="hidden" type=text name=DaysToAdd size=4 value=0 onFocus="this.select()" onMouseOver="this.focus()">
<input type=text name="display" size=20 value="">
<input type=button value="提取当前时间" onClick="AddDays(this.form)" name="button">
</form>
</center>
</body>
</html>
提取的时间样式是:2015/6/23 下午6:12:51(这个不好看)
我想要的样式是:2015年06月23日 18:13:51
或者是:2015-06-23 18:13:51 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏50(财富值+成长值)
展开全部
<form name=form>
<input type="hidden" type=text name=DaysToAdd size=4 value=0 onFocus="this.select()" onMouseOver="this.focus()">
<input type=text name="display" size=20 value="">
<input type=button value="提取当前时间" onClick="AddDays(this.form)" name="button"><script language="JavaScript">
<!--
function CurentTime()
{
var now = new Date();
var year = now.getFullYear(); //年
var month = now.getMonth() + 1; //月
var day = now.getDate(); //日
var hh = now.getHours(); //时
var mm = now.getMinutes(); //分
var ss = now.getSeconds(); //秒
var clock = year + "-";
if(month < 10)
clock += "0";
clock += month + "-";
if(day < 10)
clock += "0";
clock += day + " ";
if(hh < 10)
clock += "0";
clock += hh + ":";
if (mm < 10) clock += '0';
clock += mm + ":";
if (ss < 10) clock += '0';
clock += ss;
return(clock);
}
function AddDays(form) {
document.form.display.value=CurentTime();}
-->
</script>
<input type="hidden" type=text name=DaysToAdd size=4 value=0 onFocus="this.select()" onMouseOver="this.focus()">
<input type=text name="display" size=20 value="">
<input type=button value="提取当前时间" onClick="AddDays(this.form)" name="button"><script language="JavaScript">
<!--
function CurentTime()
{
var now = new Date();
var year = now.getFullYear(); //年
var month = now.getMonth() + 1; //月
var day = now.getDate(); //日
var hh = now.getHours(); //时
var mm = now.getMinutes(); //分
var ss = now.getSeconds(); //秒
var clock = year + "-";
if(month < 10)
clock += "0";
clock += month + "-";
if(day < 10)
clock += "0";
clock += day + " ";
if(hh < 10)
clock += "0";
clock += hh + ":";
if (mm < 10) clock += '0';
clock += mm + ":";
if (ss < 10) clock += '0';
clock += ss;
return(clock);
}
function AddDays(form) {
document.form.display.value=CurentTime();}
-->
</script>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询