繁体   English   中英

在使用javascript显示可读日期方面需要帮助

[英]Need help on displaying readable date using javascript

我是javascript新手,因此出现了显示日期的问题。

我想显示格式为MM-DD-YYYY的可读日期,但是每次尝试加载页面时,我总是会得到一个ASP格式的日期。

有人提供了此代码,但我尝试在我的项目上使用它,但是,仍然出现这种错误的日期格式错误Uncaught TypeError: Cannot call method 'formatDate' of undefined

此代码有什么问题?

$(document).ready(function () {
var date = $.datepicker.formatDate('yy-mm-dd', new Date($("#dateOfBirth").val()));
$("#dateOfBirth").val(date);
});

我正在使用C#MVC。

可以尝试一下(假设您使用的是jQuery ...如果我走了,我很抱歉):

// You might not need the next two lines...
// And if not, just delete them as well as the last line
jQuery.noConflict();
jQuery(function($) {
  $(document).ready(function() {
    $("#dateOfBirth").datepicker();
    $("#dateOfBirth").datepicker("dateFormat", "yy-mm-dd");
  });
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM