WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#31121 closed defect (bug) (fixed)

Add leading zeros to 24 hour date formats

Reported by: iseulde Owned by: dd32
Milestone: 4.2 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch commit
Focuses: Cc:

Description

There are a lot of occurrences in core where we use G:i for a 24 hour time format. This leads to weird things like 0:11 and 1:22:33. In general we should never use the G for displaying dates. g should be used for 12 hour time formats since it's a value between 1 and 12. Either it's H:i or g:i.

Attachments (1)

31121.patch (8.4 KB) - added by iseulde 6 years ago.

Download all attachments as: .zip

Change History (7)

@iseulde
6 years ago

#1 @iseulde
6 years ago

  • Keywords has-patch added

Also added a space for g:ia and decapitalised g:i A since we use a everywhere else.

Last edited 6 years ago by iseulde (previous) (diff)

#2 @DrewAPicture
6 years ago

  • Keywords dev-feedback added
  • Owner set to dd32
  • Status changed from new to reviewing

@dd32: Have an opinion one way or the other?

#3 @dd32
6 years ago

  • Keywords dev-feedback removed

Agreed. We should only be using either of:

  • H:i - [00-23]:[00-59]
  • g:i a - [1-12]:[00-59] [am-pm]

which the patch does, I also agree on a space between minutes and the meridiem

The following shouldn't be used:

  • h - [0-23]
  • G - [00-12] (especially not without the meridiem specified)
Last edited 6 years ago by dd32 (previous) (diff)

This ticket was mentioned in Slack in #core by drew. View the logs.


6 years ago

#5 @DrewAPicture
6 years ago

  • Keywords commit added

Seems sensible. Patch applies. Moving for commit consideration.

#6 @dd32
6 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 31862:

Remove ambiguity in the time display format in core, switches to using 24hr notation where am/pm isn't specified.

  • H:i - 09:54
  • g:i a - 9:54 am
  • F j, Y - January 3, 2015

These shouldn't be used without a/A (am/AM)

  • h:i - 01:23
  • G:i - 1:23

Props iseulde. Fixes #31121

Note: See TracTickets for help on using tickets.