Skip to content

Instantly share code, notes, and snippets.

@ryantbrown
Last active April 30, 2018 08:56
Show Gist options
  • Save ryantbrown/a200f555d819cd87884b12a1b4811bd0 to your computer and use it in GitHub Desktop.
Save ryantbrown/a200f555d819cd87884b12a1b4811bd0 to your computer and use it in GitHub Desktop.
Get days, hours and minutes that have passed from a given date
<?php
// get interval
// format of $datetime is "Y-m-d H:i:s"
$interval = (new \DateTime("now"))->diff(new \DateTime($datetime));
// get specific times
list($days, $hours, $minutes) = explode(" ", $interval->format("%d %h %i"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment