您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

JS实现动态计算两时间差

2024/6/28 0:43:03发布19次查看
@model rightmobilesite.models.pulse @{ viewbag.title = "setdates"; } <h2>setdates</h2> <div> @html.actionlink("pulse", "editpulse", new { pulseid = model.pulseid }) &gt; @html.label("set dates", "setdates") &gt; @html.actionlink("view pulse", "viewpulse",new { pulseid=model.pulseid }) &gt; @html.actionlink("select audience", "index") &gt; @html.actionlink("send for approval", "index") </div> <script src="@url.content("~/scripts/jquery.validate.min.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> <script src="@url.content("~/scripts/jquery.ui.datetimepicker.js")" type="text/javascript"></script> <script type="text/javascript"> <!-- function datediff(interval, date1, date2) { var objinterval = { 'd': 1000 * 60 * 60 * 24, 'h': 1000 * 60 * 60, 'm': 1000 * 60, 's': 1000, 't': 1 }; interval = interval.touppercase(); var dt1 = new date(date.parse(date1.replace(/-/g, '/'))); var dt2 = new date(date.parse(date2.replace(/-/g, '/'))); try { return math.round((dt2.gettime() - dt1.gettime()) / eval('objinterval.' + interval)); } catch (e) { return e.message; } } function calc() { var a = $("input#pulsestartdate").val(); var b = $("input#pulsefinishdate").val(); return datediff('d',a,b); } function setretval() { $("input#duration").val(calc()); return (true); } //--> $(function () { $("input#pulsestartdate").datetimepicker(); $("input#pulsefinishdate").datetimepicker(); $("input#duration").val(calc()); $("input#pulsestartdate").change(function () { setretval(); }); $("input#pulsefinishdate").blur(function () { setretval(); }); $("input#pulsefinishdate").change(function () { setretval(); }); }); </script> @using (html.beginform()) { @html.hiddenfor(model => model.pulseid) @html.validationsummary(true) <fieldset> <legend>pulse</legend> <div class="editor-label"> @html.labelfor(model => model.pulsestartdate) </div> <div class="editor-field"> @html.editorfor(model => model.pulsestartdate) @html.validationmessagefor(model => model.pulsestartdate) </div> <div class="editor-label"> @html.labelfor(model => model.pulsefinishdate) </div> <div class="editor-field"> @html.editorfor(model => model.pulsefinishdate) @html.validationmessagefor(model => model.pulsefinishdate) </div> <div class="editor-label"> @html.label("pulse duration") </div> <div class="editor-label"> <input type="text" id="duration"/> @html.label("days") </div> <p> <input type="submit" value="setdates" /> </p> </fieldset> }
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product