Last active
March 28, 2021 11:53
-
-
Save Kehet/b44d0e03dd48539b1544708473781480 to your computer and use it in GitHub Desktop.
laravel blade tag for formatting dates. place this into app/Providers/AppServiceProvider.php::boot
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 | |
Blade::directive('fancytime', function ($time) { | |
return "<abbr title=\"<?php echo " . $time . "->format('d.m.Y H:i:s'); ?>\">" . | |
"<time datetime=\"<?php echo " . $time . "->toIso8601String(); ?>\">" . | |
"<?php echo " . $time . "->diffForHumans(); ?>" . | |
"</time>" . | |
"</abbr>"; | |
}); |
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
@props(['time']) | |
<abbr title="{{ $time->format('d.m.Y H:i:s') }}"> | |
<time datetime="{{ $time->toIso8601String() }}"> | |
{{ $time->diffForHumans() }} | |
</time> | |
</abbr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment