Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wee statamic add-ons
<?php
/**
* Time for humans
* {{ time_for_humans when="insert a time and/or date in any format here" }}
* For more details see: http://carbon.nesbot.com/docs/#api-humandiff
*/
use \Carbon\Carbon;
class Plugin_time_for_humans extends Plugin
{
public function index()
{
$when = $this->fetchParam('when', null, null, false, false);
return Carbon::parse($when)->diffForHumans();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment