使用FullCalendar与MVC 4和C#,无法得到的开始和结束参数值 [英] Using FullCalendar with MVC 4 and C#, unable to get the start and end param values

查看:650
本文介绍了使用FullCalendar与MVC 4和C#,无法得到的开始和结束参数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 FullCalendar v 2.3.1 的)试图让我在控制器 $ C的事件数据$ C,开始和结束参数对象看起来是这样的:

 开始= 1425186000
结束= 1428811200

这是我应该得到的 ISO8601 日期作为参数,但显然我不是。

的文档状态

我如何获得FullCalendar提供的 ISO8601 的日期?
什么是数字,我实际上得到?


解决方案

这是UNIX时间戳,并在你的情况重新presents 2015年3月1日(启动)至2015年4月12日,(结束)。


  

一个Unix时间戳(或纪元时间)是有秒数
  1970年以来UTC 00:00 1月1日结束。 SRC


您可以得到任何转换UNIX时间戳(如下图所示)或更好的解决方案是简单地养活ISO日期的日历。 <一href=\"http://stackoverflow.com/questions/114983/given-a-datetime-object-how-do-i-get-a-iso-8601-date-in-string-format\">This SO帖子讨论如何转换的DateTime 至ISO。

\r
\r

$('#fullCal')。fullCalendar({\r
  事件:[{\r
    标题:随机事件,\r
    开始:时刻()加(1,H),\r
    结束:时刻()增加(2,H),\r
    allDay:假的\r
  },{\r
    标题:'你的Unix的事件...没有工作',//这可能是你目前code是做\r
    启动:1425186000,\r
    结束:1428811200,\r
    allDay:假的\r
  },{\r
    标题:'你的事件Unix的......工作!',//这将工作\r
    启动:moment.unix(1425186000)\r
    结束:moment.unix(1428811200)\r
    allDay:假的\r
  }],\r
  标题:{\r
    剩下: '',\r
    中心:'$ P $光伏标题旁边今天,\r
    对: ''\r
  },\r
  时区:本地\r
});

\r

&LT;脚本SRC =htt​​ps://ajax.googleapis.com/ajax /libs/jquery/2.1.0/jquery.min.js\"></script>\r
&LT;脚本的src =// cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment.min.js\"></script>\r
&LT;链接HREF =htt​​ps://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.1/fullcalendar.min.css的rel =stylesheet属性/&GT;\r
&LT;脚本src=\"https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.1/fullcalendar.min.js\"></script>\r
\r
&LT; D​​IV ID =fullCal&GT;&LT; / DIV&GT;

\r

\r
\r

When my FullCalendar (v 2.3.1) attempts to get its event data in my Controller code, start and end parameters object looks like this:

start=1425186000
end=1428811200

The documentation states that I should be getting ISO8601 dates as the parameters but obviously I am not.

How do I get the FullCalendar to provide ISO8601 dates? What are the numbers that I am actually getting?

解决方案

That is the UNIX timestamp, and in your case represents March 1, 2015 (start) to April 12, 2015 (end).

A Unix timestamp (or epoch time) is the number of seconds that have elapsed since January 1, 1970 00:00 UTC. src

You can get either convert the unix timestamp (shown below) or the better solution would be to simply feed the ISO date to the calendar. This SO post discusses how to convert a DateTime to ISO.

$('#fullCal').fullCalendar({
  events: [{
    title: 'Random Event',
    start: moment().add(1, 'h'),
    end: moment().add(2, 'h'),
    allDay: false
  }, {
    title: 'Your Event Unix... No work!', //this is probably what your current code is doing
    start: 1425186000,
    end: 1428811200,
    allDay: false
  }, {
    title: 'Your Event Unix... work!', //this will work
    start: moment.unix(1425186000),
    end: moment.unix(1428811200),
    allDay: false
  }],
  header: {
    left: '',
    center: 'prev title next today',
    right: ''
  },
  timezone: 'local'
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.1/fullcalendar.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.1.1/fullcalendar.min.js"></script>

<div id="fullCal"></div>

这篇关于使用FullCalendar与MVC 4和C#,无法得到的开始和结束参数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆