我正在创建部分视图。我需要获取自 2012.04.01 以来经过的秒数
public PartialViewResult SitePowered()
{
var dateTime = new DateTime(2012, 4, 1);
var totalSeconds = (DateTime.Now - dateTime).TotalSeconds;
ViewBag.TotalSeconds = totalSeconds;
return PartialView("SitePowered");
}
看法:
<script type="text/javascript">
$(function () {
$.getJSON("/Home/SitePowered", null, setTime);
});
</script>
@ViewBag.TotalSeconds секунд
但它不起作用