首页 > 代码库 > time
time
public ActionResult GetAllList() {
var list = db.Movies.ToList();
return Json(list, JsonRequestBehavior.AllowGet); //return Content(a);
}
@section Scripts{ <script type="text/javascript"> function formatNumToDate(value) { var now = eval(value.replace(/\/Date\((\d+)\)\//gi, "new Date($1)"));///.../gi是用来标记正则开始和结束;\是转义符;()标注了正则匹配分组1,$1 var year = now.getYear() + 1900; var month = now.getMonth() + 1; var date = now.getDate(); var hour = now.getHours(); var minute = now.getMinutes(); var second = now.getSeconds(); return year + "-" + compareNine(month) + "-" + compareNine(date) + " " + compareNine(hour) + ":" + compareNine(minute) + ":" + compareNine(second); } $(document).ready(function () { function ChangeDateFormat(time) { if (time != null) { var date = new Date(parseInt(time.replace("/Date(", "").replace(")/", ""), 10)); var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate(); return date.getFullYear() + "-" + month + "-" + currentDate; } return ""; } $("#TestList").click(function () { $.getJSON("/Movies/GetAllList", {}, function (result) { alert(result); $.each(result, function (i, field) { //var datetime = field.ReleaseDate.formatNumToDate(); alert(i + " " + ChangeDateFormat(field.ReleaseDate)); }); }); }); }); </script> }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。