选择语言 :

 Core_Date::adjust

Adjusts a non-24-hour number into a 24-hour number.

$hour = Date::adjust(3, 'pm'); // 15

string Core_Date::adjust( integer $hour , string $ampm )

参数列表

参数 类型 描述 默认值
$hour integer Hour to adjust
$ampm string AM or PM
返回值
  • string
File: ./core/classes/date.class.php
public static function adjust($hour, $ampm)
{
    $hour = (int)$hour;
    $ampm = strtolower($ampm);

    switch ( $ampm )
    {
        case 'am' :
            if ( $hour == 12 )
            {
                $hour = 0;
            }
            break;
        case 'pm' :
            if ( $hour < 12 )
            {
                $hour += 12;
            }
            break;
    }

    return sprintf('%02d', $hour);
}