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

For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:GetHumanTimestamp extensions.


  • &$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