Advertisement:

Author Topic: Is it possible to change the order of the Time Stamp?  (Read 303 times)

Offline Dwev

  • Jr. Member
  • **
  • Posts: 259
Is it possible to change the order of the Time Stamp?
« on: February 17, 2021, 06:13:20 PM »
Above every post there's a time stamp with the number for the reaction, for instance "Reply #1: Today at 04:07:09 PM"

The code for this in Display.template.php for our forum is as follows (the word "on" is already removed):

Code: [Select]
<div class="smalltext">', !empty($message['counter']) ? $txt['reply_noun'] . ' #' . $message['counter'] : ' ', ' ', $message['time'], '</div>

I was wondering if it's possible to change the order, so that it would be as follows: "Today at 04:07:09 PM - Reply #1".
Does anyone know what code I can use for this? (tried quite some variations, but keep getting errors and the forum stops working).

Thank in advance.

Offline shadav

  • Support Specialist
  • Sophist Member
  • *
  • Posts: 1,278
  • Gender: Female
    • shadav on Facebook
    • leashadav on GitHub
    • Ask The Muslims: A Place To Ask Honest Questions and Receive Respectful Answers
Re: Is it possible to change the order of the Time Stamp?
« Reply #1 on: February 17, 2021, 06:32:33 PM »
I'm not quite sure but going by what you posted, i haven't tried, I'd say something like

Code: [Select]
<div class="smalltext">', !empty($message['counter']) ? ', $message['time'], ' -  $txt['reply_noun'] . ' #' . $message['counter']' ', '</div>

Offline Matthias

  • Jr. Member
  • **
  • Posts: 163
  • Gender: Male
Re: Is it possible to change the order of the Time Stamp?
« Reply #2 on: February 17, 2021, 06:41:13 PM »
Have a look at 
Administration Center » Features and Options » General
Default time format

There you can change the time format for your needs.


Time Format
You have the power to adjust how the time and date look for yourself. There are a lot of little letters, but it's quite simple. The conventions follow PHP's strftime function and are described as below (more details can be found at php.net).

The following characters are recognized in the format string:
  %a - abbreviated weekday name
  %A - full weekday name
  %b - abbreviated month name
  %B - full month name
  %d - day of the month (01 to 31)
  %D* - same as %m/%d/%y
  %e* - day of the month (1 to 31)
  %H - hour using a 24-hour clock (range 00 to 23)
  %I - hour using a 12-hour clock (range 01 to 12)
  %m - month as a number (01 to 12)
  %M - minute as a number
  %p - either "am" or "pm" according to the given time
  %R* - time in 24 hour notation
  %S - second as a decimal number
  %T* - current time, equal to %H:%M:%S
  %y - 2 digit year (00 to 99)
  %Y - 4 digit year
  %% - a literal '%' character

* Does not work on Windows-based servers.


Time offset is available at every user profile for themselves:
Profile of {user} » Look and Layout
Time Offset
Quality first

Offline shadav

  • Support Specialist
  • Sophist Member
  • *
  • Posts: 1,278
  • Gender: Female
    • shadav on Facebook
    • leashadav on GitHub
    • Ask The Muslims: A Place To Ask Honest Questions and Receive Respectful Answers
Re: Is it possible to change the order of the Time Stamp?
« Reply #3 on: February 17, 2021, 06:50:35 PM »
 ;D not quite what they were asking for though but handy to know

on display.template.php they want to change the wording around from message number : timestamp to timestamp - message number

Offline Antechinus

  • SMF Friend
  • SMF Master
  • *
  • Posts: 25,655
  • Master of BBC Abuse
Re: Is it possible to change the order of the Time Stamp?
« Reply #4 on: February 17, 2021, 07:00:37 PM »
Code: [Select]
<div class="smalltext"> ', $message['time'], ' - ', !empty($message['counter']) ? $txt['reply_noun'] . ' #' . $message['counter'] : ' ', '</div>

Should work.

Offline Dwev

  • Jr. Member
  • **
  • Posts: 259
Re: Is it possible to change the order of the Time Stamp?
« Reply #5 on: February 18, 2021, 04:11:00 AM »
Code: [Select]
<div class="smalltext"> ', $message['time'], ' - ', !empty($message['counter']) ? $txt['reply_noun'] . ' #' . $message['counter'] : ' ', '</div>

@shadav and Antechinus: thanks a lot, that worked like a charm!
The only snag turned out the hyphen (-) between the time and the reaction number, because that looked strange on the very first reaction (that doesn't have a number, of course).

So I replaced the hyphen with two non-breaking spaces, so the final code is this:

Code: [Select]
<div class="smalltext"> ', $message['time'], ' &nbsp&nbsp ', !empty($message['counter']) ? $txt['reply_noun'] . ' #' . $message['counter'] : ' ', '</div>

Offline Antechinus

  • SMF Friend
  • SMF Master
  • *
  • Posts: 25,655
  • Master of BBC Abuse
Re: Is it possible to change the order of the Time Stamp?
« Reply #6 on: February 18, 2021, 02:53:44 PM »
You can do it like this instead, if you want a hyphen once posts have numbers:

Code: [Select]
<div class="smalltext"> ', $message['time'] !empty($message['counter']) ? ' - ' . $txt['reply_noun'] . ' #' . $message['counter'] : ' ', '</div>