钩子文档

human_time_diff

💡 云策文档标注

概述

human_time_diff 是一个 WordPress 过滤器,用于修改两个时间戳之间的人类可读时间差输出。它允许开发者自定义时间差字符串的格式或内容。

关键要点

  • 过滤器名称:human_time_diff
  • 参数:$since(时间差文本)、$diff(秒数差)、$from(起始时间戳)、$to(结束时间戳)
  • 用途:在 human_time_diff() 函数中调用,用于过滤时间差输出
  • 相关函数:human_time_diff() 位于 wp-includes/formatting.php
  • 版本历史:自 WordPress 4.0.0 引入

📄 原文内容

Filters the human-readable difference between two timestamps.

Parameters

$sincestring
The difference in human-readable text.
$diffint
The difference in seconds.
$fromint
Unix timestamp from which the difference begins.
$toint
Unix timestamp to end the time difference.

Source

return apply_filters( 'human_time_diff', $since, $diff, $from, $to );

Changelog

Version Description
4.0.0 Introduced.