Skip to content

Instantly share code, notes, and snippets.

@twysto
Last active November 10, 2022 09:54
Show Gist options
  • Save twysto/a9c8caf7a9a727814ec7bd3e3c4113b7 to your computer and use it in GitHub Desktop.
Save twysto/a9c8caf7a9a727814ec7bd3e3c4113b7 to your computer and use it in GitHub Desktop.
Time spent (Hours minutes seconds) using Carbon
<?php // Run it at: https://web.tinkerwell.app
use Carbon\Carbon;
$datetime_start = Carbon::now()->subHours(1)->subMinutes(05)->subSeconds(42);
echo $datetime_start->format('Y-m-d H:i:s') . "\r\n";
$datetime_end = Carbon::now();
$timestamp_ms_end = $datetime_end->getTimestamp();
echo $datetime_end->format('Y-m-d H:i:s') . "\r\n";
echo $datetime_start->longAbsoluteDiffForHumans($datetime_end, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment