Are there any best practices for manually adding milliseconds or microseconds to PHP date output?

When manually adding milliseconds or microseconds to PHP date output, it's important to use the DateTime class along with the date_format function to ensure accurate formatting. One approach is to create a DateTime object with the desired date and time, then use the modify method to add the milliseconds or microseconds. Finally, format the modified date object using the date_format function to display the result.

$date = new DateTime('2023-10-15 08:30:00');
$date->modify('+123 milliseconds');

echo $date->format('Y-m-d H:i:s.u');