On the environmental dependence of halo formation