Download the PHP package hananils/kirby-date-methods without Composer

On this page you can find all versions of the php package hananils/kirby-date-methods. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package kirby-date-methods

Date Methods is a plugin for Kirby 3 that allows for advanced date and time parsing and formatting using PHP's core date objects. It offers methods for fields to handle single dates, methods for pages to handle multiple dates (ranges) and also provides helper functions to simplify working with dates and times in general.

Overview

There are four types of methods:

1. Converters

Converters read a date string and convert it to PHP date and time objects like DateTime, DateTimeImmutable or DateInterval or arrays.

2. Formatters

Formatters read a date string and return a formatted and localized string, either absolute or relative.

3. Modifiers

Modifiers adjust dates to the current day, month or year which is helpful when you need to display the birthday of a person this year.

4. Validators

Installation

Download

Download and copy this repository to /site/plugins/date-methods.

Git submodule

Composer

Field methods

Field methods can be called on any field storing date information in a PHP-readable format.

toDateTime()

Returns a DateTime representation of the field value, see supported formats.

toDateTimeImmutable()

Returns a DateTimeImmutable representation of the field value, see supported formats.

toDateInterval()

Returns a DateInterval representation of the field value, see supported formats.

toDateDiff($to)

Returns a DateInterval object representing the difference between the field's date and the given date. The provided date can either be a DateTime object or a PHP-readable string, defaults to the difference to now.

toDateRounded($interval, $reference)

Returns a DateTime representation of the field's value rounded the given interval.

toFormatted($datetype, $timetype, $timezone, $calendar, $pattern)

Returns a localized, formatted date using IntlDateFormatter, see options.

The locale is set based on the current Kirby language in a multilangual setup or on the locale config setting otherwise.

toFormattedPattern($pattern)

Returns a localized date formatted by the given pattern, see symbol table for reference. Shortcut to toFormatted.

toRelative($from)

Returns a human readable time difference to the given date, e. g. just now, 2 years ago, in 5 minutes. The given date can be a DateTime object or any PHP-readable date string, see supported formats.

toTime($format)

Returns the formatted time of the given field value.

toCurrentYear()

Creates a DateTime representation of the field value and returns it with the year set to the current one.

toCurrentMonth()

Creates a DateTime representation of the field value and returns it with the month set to the current one.

toCurrentDay()

Creates a DateTime representation of the field value and returns it with the day set to the current one.

toAge($on, $format)

Calculates the difference difference between the field value and the given date. Returns the difference in the given format, see format options. Useful to calculate the age of a person.

isEarlierThan($date, $equal)

Checks it the field value is earlier than or equal to the given date.

IsLaterThan($date, $equal)

Checks it the field value is later than or equal to the given date.

Pages methods

toDateRange($fieldStart, $fieldEnd)

Returns a human-readable date range for the given dates:

Returns a human-readable date range for the given dates and times:

The formatting is provided by Ranger.

toDatePeriod($fieldStart, $fieldEnd, $interval)

Returns a DatePeriod object for the values of the given fields and interval.

toDates($fieldStart, $fieldEnd, $interval, $format)

Returns the dates of the period for the values of the given fields and interval.

Helpers

These helpers are used under the hood of the field and page methods and can be used outside of the field or pages context by passing date strings.

datetime($datetime)

Returns a DateTime object from the given date and time string. Directly returns the input if it's a DateTime object already.

-$datetime: the date, defaults to now.

dateRelative($to, $from, $locale)

Returns a human readable time difference to the given date, e. g. just now, 2 years ago, in 5 minutes. The given date can be a DateTime object or any PHP-readable date string, see supported formats.

dateFormatted($locale, $datetime, $datetype, $timetype, $timezone, $calendar, $pattern)

Returns a localized, formatted date using IntlDateFormatter, see options.

dateRounded($datetime, $interval, $reference)

Returns a DateTime representation of the field's value rounded the given interval.

dateRange($to, $from)

Returns a human-readable date range for the given dates and times:

The formatting is provided by Ranger.

normalizeDate($string)

Converts the given date string to Y-m-d format.

normalizeTime($string)

Converts the given date string to H:i format.

Options

There are several options to customize the plugin behaviour:

option description default
code The locale de
rangeseparator The string used to separate a date range, e.g. 01.08.–05.08.24
datetimeseparator The string used to separate date and time, e.g. 01.08., 10:00 ,
datetype The date format used.
Must be one of the predefined constants in IntlDateFormatter
IntlDateFormatter::LONG
timetype The time format used.
Must be one of the predefined constants in IntlDateFormatter
IntlDateFormatter::SHORT

License

This plugin is provided freely under the hana+nils · Büro für Gestaltung. We create visual designs for digital and analog media.


All versions of kirby-date-methods with dependencies

PHP Build Version
Package Version
Requires getkirby/composer-installer Version ^1.1
openpsa/ranger Version ^0.5.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hananils/kirby-date-methods contains the following files

Loading the files please wait ....