【问题标题】:MySQL DATE_FORMAT duplicate specifiersMySQL DATE_FORMAT 重复说明符
【发布时间】:2014-04-13 21:20:28
【问题描述】:

有人能解释一下difference between the %h and %I吗?两者都被描述为“小时(01..12)”并且与秒%s%S相同?这背后有什么“奇怪”的功能吗?重复的原因是什么?

【问题讨论】:

    标签: mysql date-format


    【解决方案1】:

    %h 和 %I,以及 %s 和 %S 是相同的。

    在代码中是这样的:

    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;
    

    即使早在 2003 年 6 月 20 日发布的版本 3.23.57(我能找到的最旧的源存档)中,它们也是相同的。

    【讨论】:

    • 有什么原因吗? ...不重要 - 只是好奇 ;-)
    猜你喜欢
    • 2014-09-09
    • 1970-01-01
    • 2018-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-16
    • 2015-11-15
    • 1970-01-01
    相关资源
    最近更新 更多