I solved my problem with this
$time = $currenttime[year].str_pad($currenttime[mon], 2, "0", STR_PAD_LEFT).str_pad($currenttime[mday], 2, "0", STR_PAD_LEFT).str_pad($currenttime[hours], 2, "0", STR_PAD_LEFT).str_pad($currenttime[minutes], 2, "0", STR_PAD_LEFT).str_pad($currenttime[seconds], 2, "0", STR_PAD_LEFT);
Is there a way to make this shorter?