简体   繁体   中英

How to get the 24 hours date format in Fullcalendar with Drupal 7

I know the options of the official documentation.

All OTHER options than the timeFormat and the axisFormat works very well but my timeFormat is always displaying as am/pm where I need 24 hours format.

/**
 * @file    
 * Processes the FullCalendar options and passes them to the integration.
 */   
    (function ($) {
    Drupal.fullcalendar.plugins.fullcalendar = {
        options: function (fullcalendar) {
            var settings = Drupal.settings.fullcalendar[fullcalendar.dom_id];
            var options = {
                dragOpacity: 0.5,  /* This option IS working*/
                timeFormat: { '': 'H:mm' },   /* This is NOT working */
                axisFormat: { '': 'H:mm' },
                columnFormat: {
                    month: 'ddd',    // Mon
                    week: 'ddd d/M', // Mon 9/7
                    day: 'dddd d/M'  // Monday 9/7
                },
...

I'm using Drupal 7, module which embed Fullcalendar library (version 1.5.1)

If you are using the Drupal 7 module Fullcalendar then you can set the time format in the configuration of the View.

Edit the View and check Settings in the Format section. Inn the Time/date Settings fieldset you can change the format.

Default is h:mm{ - h:mm}. Change this to HH:mm{ - HH:mm} for the 24 hour time notation. 在此输入图像描述

According to the documentation for timeFormat the 24 hour format is denoted by HH . Try changing your code to this:

(function ($) {

Drupal.fullcalendar.plugins.fullcalendar = {
  options: function (fullcalendar) {
    var settings = Drupal.settings.fullcalendar[fullcalendar.dom_id];
    var options = {
    dragOpacity: 0.5,  /* This option IS working*/
timeFormat: { '': 'HH:mm' },   /* This is NOT working */
axisFormat: { '': 'HH:mm' },
    columnFormat: {
            month: 'ddd',    // Mon
            week: 'ddd d/M', // Mon 9/7
            day: 'dddd d/M'  // Monday 9/7
    },
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM