javascript 全日历时间格式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15978811/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 02:47:56  来源:igfitidea点击:

fullcalendar time format

javascriptjquerytimefullcalendar

提问by Ricardo

Good afternoon, I know that this topic has been discussed on previous ocassions, nevertheless despite the different threads I still can't solve my problem. I am using the full calendar provided at http://arshaw.com/fullcalendar/, and they have two ways of displaying time, "10:30a"-"7p", for example. I want the time displayed on the calendar of events that are not full day, in a format "12:00 pm" or "12:00 am". The problem i'm having is, when you download the fullcalendar you have several files:

下午好,我知道这个话题已经在以前的场合讨论过,尽管有不同的话题,我仍然无法解决我的问题。我正在使用http://arshaw.com/fullcalendar/提供的完整日历,它们有两种显示时间的方式,例如“10:30a”-“7p”。我希望在非全天的事件日历上以“12:00 pm”或“12:00 am”的格式显示时间。我遇到的问题是,当您下载 fullcalendar 时,您有几个文件:

fullcalendar.js, fullcalendar.css, fullcalendar.min.js, fullcalendar.print.css, gcal.js, jquery-1.9.1.min, jquery-ui-1.10.2.custom.min

fullcalendar.js, fullcalendar.css, fullcalendar.min.js, fullcalendar.print.css, gcal.js, jquery-1.9.1.min, jquery-ui-1.10.2.custom.min

I tried what other threads suggest, which is a change in the fullcalendar.js at the time format and setdefault methods but to no avail. I can even delete the file "fullcalendar.js" and my test still works just fine. I want to know why is this and if the time format is not managed there, where is it managed? Thanks

我尝试了其他线程的建议,这是 fullcalendar.js 在时间格式和 setdefault 方法中的更改,但无济于事。我什至可以删除文件“fullcalendar.js”,我的测试仍然可以正常工作。我想知道这是为什么,如果时间格式不在那里管理,它在哪里管理?谢谢

回答by Pedram Vdl

Use this and it's going to work:

使用它,它将起作用:

$('#calendar').fullCalendar({
 timeFormat: 'hh:mm a'
});

回答by Maksim Luzik

If you are using timelineDay view, I found out that this setting will change the time format:

如果您使用时间轴日视图,我发现此设置将更改时间格式:

slotLabelFormat:"HH:mm"

回答by Mrudula Balachander

You can use this:

你可以使用这个:

axisFormat: 'h:mm a'

回答by Lucas Pretti

First I think you are confused with so many files, but basically you need only need the minified of the javascript and css to make it work.

首先,我认为您对这么多文件感到困惑,但基本上您只需要缩小 javascript 和 css 即可使其工作。

Second, I had the same problem when displaying the time correctly. This is what I did, it is a bit of workaround but it worked for me, sorry if its dirty.

其次,我在正确显示时间时遇到了同样的问题。这就是我所做的,这是一种解决方法,但它对我有用,如果它很脏,抱歉。

When you initialise the calendar you have to put the option for the timeformat so it shows the minutes even if its rounded hours.

当您初始化日历时,您必须为时间格式设置选项,以便它显示分钟,即使是四舍五入的小时数。

jQuery('#calendar').fullCalendar({ timeFormat: 'h:mm t' });

Then it was appearing only the "a" or "p" not "am" or "pm" so I used a little bit of CSS magic to add the "m" at the end, I created the rule:

然后它只出现了“a”或“p”而不是“am”或“pm”所以我使用了一点CSS魔法在最后添加了“m”,我创建了规则:

.fc-time:after { content: "m"; }

now you might mess up with the week view so you add the rule

现在你可能会弄乱周视图,所以你添加了规则

.fc-axis.fc-time:after { content: " "; }

And now hopefully you have it the way you want.

现在希望你能以你想要的方式拥有它。

Regards

问候

回答by Souhaieb

in fullcalendar v3, they use moment.jsto format time, you can format using, timeFormat: 'h:mm A', you can change between quote with input in this moment js docs page

fullcalendar v3 中,他们使用moment.js来格式化时间,您可以使用 timeFormat: 'h:mm A' 进行格式化,您可以在此时 js 文档页面中在引号和输入之间进行更改

回答by Maani

In your scheduler.fullcalendar.js file look for the events:[],and under it add this line timeFormat: 'hh:mm A',it will show time like this 10:20 PM and if u want to show time like this 10:20 Pm use small a

在您的 scheduler.fullcalendar.js 文件中查找事件:[],并在其下添加这一行 timeFormat: 'hh:mm A',它将显示像这样 10:20 PM 的时间,如果你想像这样显示时间10:20 Pm 使用小a

回答by tocallaghan

fullcalendar allows you to change the default times by setting the time format (http://arshaw.com/fullcalendar/docs/text/timeFormat/). Probably better than changing the source code.

fullcalendar 允许您通过设置时间格式 ( http://arshaw.com/fullcalendar/docs/text/timeFormat/)来更改默认时间。可能比更改源代码更好。

I think the reason your solution isn't working is because you are including fullcalendar.js and fullcalendar.min.js. These files contain the same code, the second one being a minified version of the first. Minified files are typically used in deployed versions of sites whereas the other version is used in development. So if you want to make changes don't include the minified version

我认为您的解决方案不起作用的原因是因为您包含了 fullcalendar.js 和 fullcalendar.min.js。这些文件包含相同的代码,第二个是第一个的缩小版本。缩小的文件通常用于站点的部署版本,而另一个版本用于开发。因此,如果您想进行更改,请不要包含缩小版本