Last active
August 29, 2015 14:03
-
-
Save felipecwb/6bef451e0fbd67a731cf to your computer and use it in GitHub Desktop.
The function unix2DosTime() case someone need.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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