Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

craftplugins/carbon-date

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Important

This plugin is no longer maintained.

Carbon Date plugin for Craft CMS

A plugin for Craft CMS that provides template access to methods of Brian Nesbitt’s popular Carbon extension for date/time handling.

Usage

{# Gets the current date/time #}
{{ 'now'|carbon }}

{# Gets the current date/time #}
{{ carbon() }}

{# Converts a date field to human relative difference (e.g. “1 year ago”) #}
{{ entry.dateField|carbon.diffForHumans }}

{# Carbon is chainable #}
{{ carbon().subMonth.subYear.toIso8601String }}

{# Carbon can also handle relative date differences #}
{% set since = '3 weeks ago'|carbon %}
{% set until = '2 weeks ago'|carbon %}
{{ since.diffForHumans(until) }} {# Outputs “1 week before” #}