How can strtotime() be used effectively to handle time calculations in PHP without encountering errors?

When using strtotime() in PHP for time calculations, it's important to provide a valid date/time string to avoid errors. One way to handle this effectively is by using date() to format the date/time string in a recognizable format before passing it to strtotime(). This ensures that strtotime() can accurately parse the input and perform the desired time calculations without encountering issues.

$dateString = '2022-01-01 12:00:00'; // Valid date/time string
$timestamp = strtotime(date('Y-m-d H:i:s', strtotime($dateString)));
echo date('Y-m-d H:i:s', $timestamp);