T3Social / NgineS

The Ultimate PHP Social Network Platform
GNU Affero General Public License v3.0
1 stars 0 forks source link

Issue: Date format can not be changed #54

Closed lisandi closed 3 years ago

lisandi commented 3 years ago

/templates/event.tpl - The date format is hard coded and should be better coded flexible so that also the European order - Day / Month / Year can be reflected. Additional the Year needs to be added as mentioned already in another point. The availability of the correct date WITH Year is especially important if events go over more than one year - i.e. course or End of Year/New Year Events

We changed it to: instead of $e you can write %d, %B write %M, and %Y for 4 digit year. That makes the reading of the template much more human understandable! the standard 24 hour format is %H:%M.

                                    <li>
                                        <div class="about-list-item">
                                            <i class="fa fa-clock fa-fw fa-lg"></i>
                                            {$event['event_start_date']|date_format:"%d %B %Y"} - {$event['event_end_date']|date_format:"%d %B %Y"}<br>
                                            <small class="text-muted">{$event['event_start_date']|date_format:"%d-%m-%y %H:%M"} {__("to")} {$event['event_end_date']|date_format:"%d-%m-%y %H:%M"}</small>
                                        </div>
                                    </li>

Wiki

https://github.com/T3Social/T3Social-Community/wiki/How-to-change-date-time-format-in-Sngine-and-T3Social

lisandi commented 3 years ago

Zamblek Team feedback concerning this issue - their answer before they closed the ticket on their support forum without providing a solution or feedback themselves!

Thanks for your feedback and concern.

Zamblek Team.

lisandi commented 3 years ago

ATTENTION the solution described in Zamblek Blog is outdated https://blog.sngine.com/change-event-date-format-from-am-pm-to-24-hours/

you can change the date format now in https://.../admincp/settings System Datetime Format

and

To change the display of the time itself on the event page Also can be done from this template on 2 lines too “content\themes\default\templates\event.tpl”

for the header in line System Datetime Format Header

                <!-- profile-meta -->
                <div class="profle-meta-wrapper">
                    <i class="fa fa-clock"></i> {$event['event_start_date']|date_format:"%d %B %Y %H:%M"} - {$event['event_end_date']|date_format:"%d %B %Y %H:%M"}
                </div>
                <!-- profile-meta -->

and for the sidebar in lines 226 and 227 System Datetime Format Sidebar

                                    <li>
                                        <div class="about-list-item">
                                            <i class="fa fa-clock fa-fw fa-lg"></i>
                                            {$event['event_start_date']|date_format:"%d %B %Y"} - {$event['event_end_date']|date_format:"%d %B %Y"}<br>
                                            <small class="text-muted">{$event['event_start_date']|date_format:"%d-%m-%y %H:%M"} {__("to")} {$event['event_end_date']|date_format:"%d-%m-%y %H:%M"}</small>
                                        </div>
                                    </li>

You can change the date_format in the template file to whatever you want

date_format conversion specifiers:

%a - abbreviated weekday name according to the current locale

%A - full weekday name according to the current locale

%b - abbreviated month name according to the current locale

%B - full month name according to the current locale

%c - preferred date and time representation for the current locale

%C - century number (the year divided by 100 and truncated to an integer, range 00 to 99)

%d - day of the month as a decimal number (range 01 to 31)

%D - same as %m/%d/%y

%e - day of the month as a decimal number, a single digit is preceded by a space (range 1 to 31)

%g - Week-based year within century [00,99]

%G - Week-based year, including the century [0000,9999]

%h - same as %b

%H - hour as a decimal number using a 24-hour clock (range 00 to 23)

%I - hour as a decimal number using a 12-hour clock (range 01 to 12)

%j - day of the year as a decimal number (range 001 to 366)

%k - Hour (24-hour clock) single digits are preceded by a blank. (range 0 to 23)

%l - hour as a decimal number using a 12-hour clock, single digits preceeded by a space (range 1 to 12)

%m - month as a decimal number (range 01 to 12)

%M - minute as a decimal number

%n - newline character

%p - either am' orpm' according to the given time value, or the corresponding strings for the current locale

%r - time in a.m. and p.m. notation

%R - time in 24 hour notation

%S - second as a decimal number

%t - tab character

%T - current time, equal to %H:%M:%S

%u - weekday as a decimal number [1,7], with 1 representing Monday

%U - week number of the current year as a decimal number, starting with the first Sunday as the first day of the first week

%V - The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week.

%w - day of the week as a decimal, Sunday being 0

%W - week number of the current year as a decimal number, starting with the first Monday as the first day of the first week

%x - preferred date representation for the current locale without the time

%X - preferred time representation for the current locale without the date

%y - year as a decimal number without a century (range 00 to 99)

%Y - year as a decimal number including the century

%Z - time zone or name or abbreviation

%z - (lowercase) is not listed here. It would print "+0100" instead of "CET" (%Z).

%% - a literal `%' character

Example: More common format should be added: YYYY-MM-DD (e.g. 2011-12-31) {$smarty.now|date_format:"%Y-%m-%d"}

Check this for this date_format (Only for this template not the JavaScript file) https://www.smarty.net/docsv2/en/language.modifier.date.format.tpl

lisandi commented 3 years ago

https://github.com/T3Social/T3Social-Community/wiki/How-to-change-date-time-format-in-Sngine-and-T3Social