Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Created December 13, 2024 14:36
Show Gist options
  • Save ziadoz/03a8804a12598bf93ca726961af68bf8 to your computer and use it in GitHub Desktop.
Save ziadoz/03a8804a12598bf93ca726961af68bf8 to your computer and use it in GitHub Desktop.
Carbon - Diff in minutes/hours/days
<?php
> \Carbon\Carbon::now()->subMinutes(60)->longAbsoluteDiffForHumans();
= "1 hour"
> \Carbon\Carbon::now()->subMinutes(1440)->longAbsoluteDiffForHumans();
= "1 day"
> \Carbon\Carbon::now()->subMinutes(1560)->longAbsoluteDiffForHumans();
= "1 day"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment