Manual:Hooks/GetHumanTimestamp

From Linux Web Expert

GetHumanTimestamp
<translate> Available from <tvar name=1><translate> version <tvar (Gerrit change 45651)</tvar></translate>
Pre-emptively override the human-readable timestamp generated by MWTimestamp::getHumanTimestamp(). Return false in this hook to use the custom output.
<translate> Define function:</translate>
public static function onGetHumanTimestamp( string &$output, MWTimestamp $timestamp, MWTimestamp $relativeTo, User $user, Language $lang ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"GetHumanTimestamp": "MediaWiki\\Extension\\MyExtension\\Hooks::onGetHumanTimestamp"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> ../languages/Language.php
<translate> Function(s):</translate> getHumanTimestamp
<translate> Interface:</translate> GetHumanTimestampHook.php

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:GetHumanTimestamp extensions</tvar>.</translate>


Details

  • &$output: string for the output timestamp
  • $timestamp: MWTimestamp object of the current (user-adjusted) timestamp
  • $relativeTo: MWTimestamp object of the relative (user-adjusted) timestamp
  • $user: User whose preferences are being used to make timestamp
  • $lang: Language that will be used to render the timestamp