Skip to content

Instantly share code, notes, and snippets.

@felipecwb
Last active August 29, 2015 14:03
Show Gist options
  • Save felipecwb/6bef451e0fbd67a731cf to your computer and use it in GitHub Desktop.
Save felipecwb/6bef451e0fbd67a731cf to your computer and use it in GitHub Desktop.
The function unix2DosTime() case someone need.
<?php
function unix2DosTime($unixtime = 0) {
$timearray = $unixtime ? getdate($unixtime) : getdate();
if ($timearray['year'] < 1980) {
$timearray['year'] = 1980;
$timearray['mon'] = 1;
$timearray['mday'] = 1;
$timearray['hours'] = 0;
$timearray['minutes'] = 0;
$timearray['seconds'] = 0;
}
return (($timearray['year'] - 1980) << 25)
| ($timearray['mon'] << 21)
| ($timearray['mday'] << 16)
| ($timearray['hours'] << 11)
| ($timearray['minutes'] << 5)
| ($timearray['seconds'] >> 1);
}
echo $time = time(); // 1405091030
echo PHP_EOL; //
echo unix2DosTime($time); // 1156286585
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment