【发布时间】:2014-01-12 10:31:30
【问题描述】:
这是代码和mysql表
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/2a", "root", "root");
Statement st=con.createStatement();
ResultSet rsta=st.executeQuery("Select * from data");
while(rsta.next()) {
x14=rsta.getTime("strtime");
}
%>
<div id="TextBoxesGroup">
<input type="hidden" id="time" name="time" value="<%=x14%>"/>
</div>
<script>
$(document).ready(function(){
var dateString=$('#time').val();
var d1 = new Date(dateString);
var newTextBoxDiv = $(document.createElement('div'))
.attr("id", 'TextBoxDiv' + counter);
newTextBoxDiv.after().html('<div><label style="float:left;">'+d1+'</label>);
newTextBoxDiv.appendTo("#TextBoxesGroup");
</script>
+---------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| date | date | YES | | NULL | |
| strtime | time | YES | | NULL | |
| endtime | time | YES | | NULL | |
| freq | varchar(30) | YES | | NULL | |
| inter | int(11) | YES | | NULL | |
+---------+-------------+------+-----+---------+----------------+
变量 d1(它在 db 中保存为时间)给了我无效的日期。为什么会发生这种情况?我错过了什么吗?
如果需要更多信息,请告诉我,但请提供帮助。
【问题讨论】:
-
检查过 dateString 的值吗?
-
它在 mycase 中给出了 db 值..11.30:00
-
var d1 = new Date("October 13, 1975 11:13:00") 这是默认格式
-
@Vishal 在建议的问题中我不能只通过时间?
标签: java javascript jquery mysql