选择语言 :

 Core_Date::unix2dos

Converts a UNIX timestamp to DOS format. There are very few cases where this is needed, but some binary formats use it (eg: zip files.) Converting the other direction is done using {@link Date::dos2unix}.

$dos = Date::unix2dos($unix);

integer Core_Date::unix2dos( [ integer $timestamp = bool false ] )

参数列表

参数 类型 描述 默认值
$timestamp integer UNIX timestamp bool false
返回值
  • integer
File: ./core/classes/date.class.php
public static function unix2dos($timestamp = FALSE)
{
    $timestamp = ($timestamp === FALSE) ? getdate() : getdate($timestamp);

    if ( $timestamp['year'] < 1980 )
    {
        return (1 << 21 | 1 << 16);
    }

    $timestamp['year'] -= 1980;

    // What voodoo is this? I have no idea... Geert can explain it though,
    // and that's good enough for me.
    return ($timestamp['year'] << 25 | $timestamp['mon'] << 21 | $timestamp['mday'] << 16 | $timestamp['hours'] << 11 | $timestamp['minutes'] << 5 | $timestamp['seconds'] >> 1);
}