ADO 记录集中的 Javascript 日期格式
我使用 JS 和 ADO 从数据库中检索日期列表,并使用以下代码将其显示在表中:
var detDate = new Date() ;
if(!rsDetail.bof) {
rsDetail.MoveFirst()
while(!rsDetail.eof) {
detDate = rsDetail.fields(2).value;
rsDetail.MoveNext()
}
... TableHtml += '<td>' + detDate + '</td>' ...
输出如下所示: Sat Oct 15 00:00:00 EDT 2011
我希望它看起来像这样:2011-10-15
我一直在查看 JS 日期对象,并尝试执行 formatDate(detDate,'y-mm-dd')
但它不起作用......
I retrieve a list of date from a DB using JS and ADO and I show it in a table with the following code:
var detDate = new Date() ;
if(!rsDetail.bof) {
rsDetail.MoveFirst()
while(!rsDetail.eof) {
detDate = rsDetail.fields(2).value;
rsDetail.MoveNext()
}
... TableHtml += '<td>' + detDate + '</td>' ...
The output looks like that: Sat Oct 15 00:00:00 EDT 2011
I want it to look like that: 2011-10-15
I have been looking around at the JS date object and I tried to do formatDate(detDate,'y-mm-dd')
but it doesn't work...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以像这样格式化日期对象:
You can format your date object like that :