Skip to content

Instantly share code, notes, and snippets.

@alehandrof
Created November 12, 2015 20:48
Show Gist options
  • Save alehandrof/64ddaf7647287fe77ed1 to your computer and use it in GitHub Desktop.
Save alehandrof/64ddaf7647287fe77ed1 to your computer and use it in GitHub Desktop.
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