Comments 1fisher1919 started the conversationJanuary 26, 2022 at 11:01amHello, 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. 975Zhivko repliedJanuary 26, 2022 at 11:59amThere 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 1fisher1919 repliedJanuary 26, 2022 at 12:23pmIt's perfect ! Thank you !1 Like Sign in to reply ...
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.
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
It's perfect ! Thank you !