- substr: documentation ( source)
- strpos: documentation ( source)
- microtime: documentation ( source)
- str_repeat: documentation ( source)
- round: documentation ( source)
- date: documentation ( source)
<?php
for($i=1;$i<1001;$i*=10)
{
$starttime=round( microtime(TRUE)*$i);
$now= shortenb64($starttime);
$len=strlen($now);
$min= str_repeat("0", $len);
$max= str_repeat("z", $len);
$nowtime=date("Y-m-d H:i:s", $nowS=epxandb64($now)/$i);
$minS=epxandb64($min)/$i;
$maxS=epxandb64($max)/$i;
$minYear = 1970+($minS/ (60*60*24*365.25));
$maxYear = 1970+($maxS/ (60*60*24*365.25));
echo "$i $starttime --- $now ($nowtime): --- min year ($minYear) --- max year ($maxYear)";
}
function shortenb64($id, $alphabet='-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz')
{
$base = strlen($alphabet);
$short = '';
while($id) {
$id = round(($id-($r=$id%$base))/$base);
$short = $alphabet{$r} . $short;
}
return $short;
}
function epxandb64($id, $alphabet='-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz')
{
$base = strlen($alphabet);
$len = strlen($id)-1;
$long = 0.0;
$mul=1;
for($i=$len;$i>=0;$i--)
{
$long += strpos($alphabet, substr($id, $i,1))*$mul;
$mul *= $base;
}
return $long;
}