Okay
  Public Ticket #2966572
Change the display format of date
Closed

Comments

  •  1
    fisher1919 started the conversation

    Hello, 

    I wish to change display format of date into ( l j F Y ) -> Wednesday 26 January 2022

    Is there a filter to insert in the functions.php file of the child theme ?

    Thank's for your help. 

  •  793
    Zhivko replied

    There is a javascript filter but I'd suggest you to override the helper function.

    Example:

    add_action('wp_footer', function () {
        if (false === wp_script_is('stec-js')) {
            return;
        }     ?>     <script type="text/javascript">
            (function($) {             $(function() {                 window.StecHelper.prototype.beautifyTimespan = function(start, end, allDay) {                     var d1, d2, format, timeFormat, delimeter, timespanLabel, formatEnd, trTimespanLabel;                     allDay = parseInt(allDay, 10);                     d1 = new moment(start);
                        d2 = end ? new moment(end) : null;                     format = 'dddd DD MMMM YYYY';
                        timeFormat = 'HH:mm';
                        delimeter = ' ';                     // Show time only if not all_day event
                        if (parseInt(allDay, 10) !== 1) {
                            format += ' ' + timeFormat;
                        }                     if (end) {                         // Same Day
                            if (d1.isSame(d2, 'day')) {                             timespanLabel = d1.format(format);                             if (parseInt(allDay, 10) !== 1) {
                                    timespanLabel += " - " + d2.format(timeFormat);
                                }                         } else                             // Same Month & Year
                                if (d1.isSame(d2, 'month')) {                                 formatEnd = format.replace('YYYY', '');                                 timespanLabel = d1.format(format);
                                    timespanLabel += " - " + d2.format(formatEnd);                             }                         // Default
                            else {                             timespanLabel = d1.format(format);
                                timespanLabel += " - " + d2.format(format);
                            }                     } else {
                            timespanLabel = d1.format(format);
                        }                     timespanLabel = timespanLabel.split(delimeter);
                        trTimespanLabel = [];                     $.each(timespanLabel, function() {                         var part = typeof window.stecLang[this.toLowerCase().trim()] !== 'undefined' ? window.stecLang[this.toLowerCase().trim()] : this;
                            part = part.charAt(0).toUpperCase() + part.slice(1);                         trTimespanLabel.push(part);
                        });                     trTimespanLabel = trTimespanLabel.join(delimeter);                     this.glob.temp.dateTimeString = trTimespanLabel[0].toUpperCase() + trTimespanLabel.substr(1);                     this.$instance.trigger('stecBeforeReturnBeautifyTimespan', {
                            $instance: this.$instance,
                            startDate: start,
                            endDate: end,
                            allDay: allDay,
                            temp: this.glob.temp
                        });                     return this.glob.temp.dateTimeString;
                    };
                });         })(window.jQuery);
        </script>
    <?php });



    Stachethemes Developer

  •  1
    fisher1919 replied

    It's perfect ! Thank you !