From prestellar to protostellar cores. II. Time dependence and deuterium fractionation