[wp-trac] [WordPress Trac] #61535: human_time_diff(): Do not use abbreviations in minutes

WordPress Trac noreply at wordpress.org
Sat Jun 29 04:34:04 UTC 2024


#61535: human_time_diff(): Do not use abbreviations in minutes
--------------------------+-----------------------------
 Reporter:  wildworks     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Formatting    |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I discovered this problem while researching an issue with Gutenberg:
 https://github.com/WordPress/gutenberg/issues/62976

 As I understand it, when relative times are displayed in the block editor,
 this format is referenced. No abbreviations are used for minutes:

 https://github.com/WordPress/wordpress-
 develop/blob/d3ac93a93839fbe5e441309607786bacdad755cd/src/wp-includes
 /script-loader.php#L444-L447

 On the other hand, in PHP, i.e. the `human_time_diff()` function,
 abbreviations (`min`/`mins`) are only used for minutes:

 https://github.com/WordPress/wordpress-
 develop/blob/d3ac93a93839fbe5e441309607786bacdad755cd/src/wp-
 includes/formatting.php#L3887-L3888

 As a result, relative times can be formatted differently depending on
 whether they're expressed in JS or PHP.

 One example is the Post Time block. If the post date is within an hour of
 the current time and relative format is enabled, it will be displayed as
 `1 minute`/`10 minutes` in the block editor and represented as `1 min` /
 `10 mins` on the frontend.

 I suggest not using abbreviations in `human_time_diff()` functions.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61535>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list