如何格式日期在FullCalendar的方式,当我点击事件? [英] How to format date on FullCalendar on that way, when I click on event?

查看:880
本文介绍了如何格式日期在FullCalendar的方式,当我点击事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在FullCalendar上以这种方式格式化日期,当我点击事件? (例如)并使用此代码:

  eventClick:function(calEvent,jsEvent,view){
alert 'start:'+ calEvent.start);
alert('end:'+ calEvent.end);
},

$ b

 开始:12/28/2013 14:55 
结束:12/28/2013 18:55

而不是Tue Dec 28 2013 ...


$

解决方案

由于fullcalendars的事件开始和结束属性是javascript Date 对象,它们负责显示它们来处理它们的格式,他们自己没有一个特定的格式。



我发现在JavaScript中处理日期最简单的方法是使用 moment.js



格式化您的警报中的日期将是类似

  alert('start: + moment(calEvent.start).format('DD / MM / yyyy hh:mm')); 


How to format date on FullCalendar on that way, when I click on event? (for example) and use this code:

  eventClick: function( calEvent, jsEvent, view ){
    alert('start: ' + calEvent.start);
    alert('end: ' + calEvent.end);
  },

that alert show something like

start: 12/28/2013 14:55   
end: 12/28/2013 18:55

instead of "Tue Dec 28 2013 ... "

Any suggestions will be appreciated.

解决方案

Since fullcalendars' event start and end properties are javascript Date objects, it is responsibility of the code that displays them to handle their formatting, they don't have a specific format by themselves.

The easiest way I found to handle dates in javascript is to use moment.js.

Formatting your date in your alert would then be something like

alert('start: ' + moment(calEvent.start).format('DD/MM/yyyy hh:mm'));

这篇关于如何格式日期在FullCalendar的方式,当我点击事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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