MyBB Community Forums

Full Version: MyAlerts timestamp.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can I change the MyAlerts timestamp to say the actual timestamp, instead of "Today"?

I thought the answer to changing it might be in myalerts.php, but can't seem to figure out what to change in there, if that's the right place.

I also thought this would give me a clue as to what I should change, but no luck.


 <td class="trow1 alert__time">
        Today
   </td>


Hi,

By default MyAlerts uses the build in MyBB date format and will use whatever format you've specified in the MyBB settings.

If you want to use a different format, you'll need to edit this line:

https://github.com/MyBBStuff/MyAlerts/bl...s.php#L629

You could just hardcode a custom date format, following the PHP date formatting explanation.
(2016-06-30, 09:41 AM)Euan T Wrote: [ -> ]Hi,

By default MyAlerts uses the build in MyBB date format and will use whatever format you've specified in the MyBB settings.

If you want to use a different format, you'll need to edit this line:

https://github.com/MyBBStuff/MyAlerts/bl...s.php#L629

You could just hardcode a custom date format, following the PHP date formatting explanation.



Thanks.

Can you give me an example of how I'd change this line to a different date/time format?

		$outputAlert['received_at'] = htmlspecialchars_uni(
			my_date(
				$mybb->settings['dateformat'],
				$alertToParse->getCreatedAt()->getTimestamp()
			)
		);


I also tried changing the time settings in configuration from "h:i A" to "h:i:s A", but don't notice a difference anywhere on the forum.

I was thinking that by including the seconds, it would stop saying X minutes ago for threadtimestamps, or "today" or "yesterday" for MyAlert timestamps, but no changes anywhere.

I tried building a few caches in my cache manager but that didn't change things either.
Hi,

The easiest way would be to edit that block to:

        $outputAlert['received_at'] = htmlspecialchars_uni(
            my_date(
                $mybb->settings['dateformat'],
                $alertToParse->getCreatedAt()->getTimestamp(),
                "",
                false
            )
        );

That should disable today/yesterday style formatting.
(2016-06-30, 06:02 PM)Euan T Wrote: [ -> ]Hi,

The easiest way would be to edit that block to:

        $outputAlert['received_at'] = htmlspecialchars_uni(
            my_date(
                $mybb->settings['dateformat'],
                $alertToParse->getCreatedAt()->getTimestamp(),
                "",
                false
            )
        );

That should disable today/yesterday style formatting.

And where do I enter my own format string?

Now it only gives a date in mm-dd-yyyy format.


	    $outputAlert['received_at'] = htmlspecialchars_uni(
		    my_date
			($mybb->settings['dateformat'], 
				$alertToParse->getCreatedAt()->getTimestamp(),
				"",
				false
			)
	    );


I tried entering the format string in the empty quotes, but it didn't help.

Also, what does the "false" signify?
(2016-07-01, 03:27 AM)nuraman00 Wrote: [ -> ]
(2016-06-30, 06:02 PM)Euan T Wrote: [ -> ]Hi,

The easiest way would be to edit that block to:

        $outputAlert['received_at'] = htmlspecialchars_uni(
            my_date(
                $mybb->settings['dateformat'],
                $alertToParse->getCreatedAt()->getTimestamp(),
                "",
                false
            )
        );

That should disable today/yesterday style formatting.

And where do I enter my own format string?

Now it only gives a date in mm-dd-yyyy format.


	    $outputAlert['received_at'] = htmlspecialchars_uni(
		    my_date
			($mybb->settings['dateformat'], 
				$alertToParse->getCreatedAt()->getTimestamp(),
				"",
				false
			)
	    );


I tried entering the format string in the empty quotes, but it didn't help.

Also, what does the "false" signify?

Hi, The "false" disables relative timestamps. For your own format string, replace "$mybb->settings['dateformat']":

	    $outputAlert['received_at'] = htmlspecialchars_uni(
		    my_date
			('d-m-Y h:i:s A', 
				$alertToParse->getCreatedAt()->getTimestamp(),
				"",
				false
			)
	    );
Perfect, thanks!

So I can set it to true to make it relative to that user, correct?
(2016-07-01, 07:15 PM)nuraman00 Wrote: [ -> ]Perfect, thanks!

So I can set it to true to make it relative to that user, correct?

If you set it to true, it'll always be true. To change it per user, you'd need a conditional to set a variable to true/false and pass that.
(2016-07-01, 09:06 PM)Euan T Wrote: [ -> ]
(2016-07-01, 07:15 PM)nuraman00 Wrote: [ -> ]Perfect, thanks!

So I can set it to true to make it relative to that user, correct?

If you set it to true, it'll always be true. To change it per user, you'd need a conditional to set a variable to true/false and pass that.

I think I'm misunderstanding what a relative timestamp is then.

If true, is a relative timestamp the timestamp of a post according to a user's time zone? Or does true mean according to the server's time zone? Or neither?
The relative timestamp is the timestamp like "Today", "Yesterday", 1 hour ago, etc.