MySQL DATE_FORMAT Duplicate Specifications

Can someone explain the difference between %hand%I ? Both of them are described as “Hour (01..12)” and the same with seconds %sand %s? Is this some kind of "weird" functionality? What is the reason for duplication?

+4
source share
1 answer

% h and% I, as well as% s and% S are identical.

In code, it looks like this:

case 'h':
case 'I':
  hours_i= (l_time->hour%24 + 11)%12+1;
  length= (uint) (int10_to_str(hours_i, intbuff, 10) - intbuff);
  str->append_with_prefill(intbuff, length, 2, '0'); 
  break;

case 'S':
case 's':
  sprintf(intbuff,"%02d",l_time.second);
  str->append(intbuff);
  break;

Even in version 3.23.57 (the oldest source archive I could find), which was released on June 20, 2003, they were identical.

+2
source

Source: https://habr.com/ru/post/1536350/


All Articles