Created
November 12, 2015 20:48
-
-
Save alehandrof/64ddaf7647287fe77ed1 to your computer and use it in GitHub Desktop.
Wee statamic add-ons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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