ディレクトリを作成したい時なんかにmicro秒を使いたい時があって
どうやったかのメモ
$time_ar = explode(" ",microtime());
echo "UnixTime:{$time_ar[1]}<br>\n";
echo "MicroTime:{$time_ar[0]}<br>\n";
echo "U+M:".$time_ar[0] + $time_ar[1];
普通にこの様に足してしまうと
UnixTime:1457315839
MicroTime:0.57940100
U+M:1457315839.5794
と出たり
UnixTime:1457315839
MicroTime:0.57900100
U+M:1457315839.579
と出たり
で、桁数が安定せず見た目が良くないので
$time_ar = explode(" ",microtime());
echo "UnixTime:{$time_ar[1]}<br>\n";
echo "MicroTime:{$time_ar[0]}<br>\n";
echo "U+M:".str_pad($time_ar[0] + $time_ar[1],15,'0',STR_PAD_RIGHT);
って感じでやると
UnixTime:1457315839
MicroTime:0.57900100
U+M:1457315839.5790
こうなって桁が揃って見栄えがいい