function showToDay(){
//封装日期
var Nowdate=new Date();
var M=Number(Nowdate.getMonth())+1;
return Nowdate.getYear()+"-"+M+"-"+Nowdate.getDate()+"-"+Nowdate.getHours;
}
这样写只有年月日,没有Hour;
//封装日期
var Nowdate=new Date();
var M=Number(Nowdate.getMonth())+1;
return Nowdate.getYear()+"-"+M+"-"+Nowdate.getDate()+"-"+Nowdate.getHours;
}
这样写只有年月日,没有Hour;
解决方案 »
- Cookie里面怎么存放中文字符,键和值都能存中文字符么
- 价钱是由类型和数量决定的,每当选择名称,选择类型后和填写数量后 价钱的值会自动随着变化,请问各位我该如何实现呢
- struts
- 如何控制文本框宽度随内容的多少变化?谢谢!
- 关于两个String类型的变量比较,输出结果一样,比较起来却不等?
- 如果上传2进制文件到sql数据库?
- 这个一百分的问题谁能拿?
- 提问:cookie中可否写中文,我的写了为什么显示乱码,并且删不掉了。怪事!哪位懂帮帮忙,多谢!
- 关于错误页,我真的很急,谢谢!!!
- Tomcat3.2下,页面乱码(点查看->编码->简体中文后恢复正常),怎么办办???
- 框架整合时老报异常是个简单问题
- 谁可给我说说简单的ASP程序
楼主【wqfwuliao】截止到2008-06-26 14:21:14的历史汇总数据(不包括此帖):
发帖数:1 发帖分:1
结贴数:1 结贴分:1
未结数:0 未结分:0
结贴率:100.00% 结分率:100.00%
敬礼!
去这里看看,这个方法也被抛弃了
String y =""+now.getYear();
String year = "20"+y.substring(1,3);
int m = now.getMonth()+1;
String month="";
int d = now.getDate();
String day = "";
int w = now.getDay();
String[] weekly = {"星期天","星期一","星期二","星期三","星期四","星期五","星期六"};
if(m<10){
month ="0"+m;
}
if(d<10){
day = "0"+d;
}else{
day = ""+d;
}
String weekday = weekly[w];
%>
<%=year %>年<%=month %>月<%=day %>日 <%=weekday %>
<body>
<%
String pattern = "yyyy-MM-dd HH:mm:ss";
Date date = new Date();
date.setTime(System.currentTimeMillis());
SimpleDateFormat format = new SimpleDateFormat(pattern);
out.print(format.format(date));
%>
</body>
正解,如果还想要毫秒的话,就在ss后面再加上SSS,记得之间要空格
=========================================
return Nowdate.getYear()+"-"+M+"-"+Nowdate.getDate()+"-"+Nowdate.getHours();
--- 可以设置你所想要的格式
<jsp:useBean id="now" class="java.util.Date"></jsp:useBean>
<fmt:formatDate value="${now}" pattern="yyyy年M月dd日"/>
在类里,f= new SimpleDateFormat(="yyyy年M月dd日") ;f.format(new Date()) ;
mysql:current_time
sqlserver:getdate()