Skip to content
Date range field for Craft CMS
PHP HTML
Branch: develop
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
CHANGELOG.md
LICENSE.md
README.md
composer.json

README.md

Date Range field for Craft CMS 3

What is says on the tin 🙂. This field gives you a start and end date in 1 field.

Requirements

This plugin requires Craft CMS 3.0.0 or later.

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
     composer require studioespresso/craft-date-range
     ./craft install/plugin date-range
    

Settings

The following options can be set on the field:

  • Show a start time field
  • Show an end time field

When the field is set to required, both start & end date (and if enabled time) will be required.

Default time values

Since a PHP DateTime object also has a time value, wether you entered on or not (or wether you have to option enabled to show the fields or not), the plugin tries to be smart in which time values get saved.

When you enable either or both time fields, that value will off course be safed. For fields that don't have time options set, 00:00:00 will get saved.

Templating

When using the field in your template, you have access to both start and end properties, as well as:

  • isPast: returns true if the end property is past the current date & time.
  • isFuture: returns true if the start property is ahead the current date & time.
  • isOnGoing: returns true if the start property is past the current date & time and the end property is ahead of the current date & time.

Brought to you by Studio Espresso

You can’t perform that action at this time.