Download the PHP package ixnode/php-date-parser without Composer

On this page you can find all versions of the php package ixnode/php-date-parser. 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 php-date-parser

PHP Date Parser

Release PHP PHPStan PHPUnit PHPCS PHPMD Rector - Instant Upgrades and Automated Refactoring LICENSE

This library parses various given date and time strings into DateTime or DateTimeImmutable classes which return the time range. Can be used e.g. excellently for command line arguments and options to make database queries with.

Examples / Usage

Date parser (UTC)

Word parser (UTC)

Date parser with timezones

Working with DateRange class

Parsing formats

Supported words

Word Description
next-second Next second ('s' + 1)
this-second This second ('s')
last-second Last second ('s' - 1)
next-minute Next minute ('i' + 1)
this-minute This minute ('i')
last-minute Last minute ('i' - 1)
next-hour Next hour ('G' + 1)
this-hour This hour ('G')
last-hour Last hour ('G' - 1)
tomorrow The day tomorrow ('j' + 1)
today The day today ('j')
yesterday The day yesterday ('j' - 1)
next-month Next month ('n' + 1)
this-month This month ('n')
last-month Last month ('n' - 1)
next-year Next year ('Y' + 1)
this-year This year ('Y')
last-year Last year ('Y' - 1)

Overview

Exact time parser (=datetime)

Given format Description From ('Y-m-d H:i:s') To ('Y-m-d H:i:s')
"next-hour" Returns the date range from the next hour. Alias of "2023-07-07 13". "2023-07-07 13:00:00" "2023-07-07 13:59:59"
"=next-hour" Alias of "next-hour". "2023-07-07 13:00:00" "2023-07-07 13:59:59"
"this-hour" Returns the date range from current hour. Alias of "2023-07-07 12". "2023-07-07 12:00:00" "2023-07-07 12:59:59"
"=this-hour" Alias of "this-hour". "2023-07-07 12:00:00" "2023-07-07 12:59:59"
"last-hour" Returns the date range from the last hour. Alias of "2023-07-07 11". "2023-07-07 11:00:00" "2023-07-07 11:59:59"
"=last-hour" Alias of "last-hour". "2023-07-07 11:00:00" "2023-07-07 11:59:59"
"tomorrow" Returns the date range from tomorrow. Alias of "2023-07-08". "2023-07-08 00:00:00" "2023-07-08 23:59:59"
"=tomorrow" Alias of "tomorrow". "2023-07-08 00:00:00" "2023-07-08 23:59:59"
"today" Returns the date range from today. Alias of "2023-07-07". "2023-07-07 00:00:00" "2023-07-07 23:59:59"
"=today" Alias of "today". "2023-07-07 00:00:00" "2023-07-07 23:59:59"
"yesterday" Returns the date range from yesterday. Alias of "2023-07-06". "2023-07-06 00:00:00" "2023-07-06 23:59:59"
"=yesterday" Alias of "yesterday" "2023-07-06 00:00:00" "2023-07-06 23:59:59"
"this-month" Date range from first day to last day this month. Alias of "2023-07-01\|2023-07-31". "2023-07-01 00:00:00" "2023-07-31 23:59:59"
"=this-month" Alias of "this-month" "2023-07-01 00:00:00" "2023-07-31 23:59:59"
"2023-07-01" Exactly the given date. "2023-07-01 00:00:00" "2023-07-01 23:59:59"
"=2023-07-01" Alias of "2023-07-01" "2023-07-01 00:00:00" "2023-07-01 23:59:59"

Time is greater than parser (>from)

Given format Description From ('Y-m-d H:i:s') To ('Y-m-d H:i:s')
">tomorrow" Later than tomorrow1) "2023-07-09 00:00:00" NULL
">=tomorrow" Later than tomorrow2) "2023-07-08 00:00:00" NULL
">+tomorrow" Alias of ">=tomorrow" "2023-07-08 00:00:00" NULL
"+tomorrow" Alias of ">=tomorrow" "2023-07-08 00:00:00" NULL
">today" Later than today1) "2023-07-08 00:00:00" NULL
">=today" Later than today2) "2023-07-07 00:00:00" NULL
">+today" Alias of ">=today" "2023-07-07 00:00:00" NULL
"+today" Alias of ">=today" "2023-07-07 00:00:00" NULL
">yesterday" Later than yesterday1) "2023-07-07 00:00:00" NULL
">=yesterday" Later than yesterday2) "2023-07-06 00:00:00" NULL
">+yesterday" Alias of ">=yesterday" "2023-07-06 00:00:00" NULL
"+yesterday" Alias of ">=yesterday" "2023-07-06 00:00:00" NULL
">2023-07-01" Later than the given date1) "2023-07-02 00:00:00" NULL
">=2023-07-01" Later than the given date2) "2023-07-01 00:00:00" NULL
">+2023-07-01" Alias of ">=2023-07-01" "2023-07-01 00:00:00" NULL
"+2023-07-01" Alias of ">=2023-07-01" "2023-07-01 00:00:00" NULL

Time is less than parser (<to)

Given format Description From ('Y-m-d H:i:s') To ('Y-m-d H:i:s')
"<tomorrow" Before tomorrow1) NULL "2023-07-07 23:59:59"
"<=tomorrow" Before tomorrow2) NULL "2023-07-08 23:59:59"
"<+tomorrow" Alias of "<=tomorrow" NULL "2023-07-08 23:59:59"
"-tomorrow" Alias of "<=tomorrow" NULL "2023-07-08 23:59:59"
"<today" Before today1) NULL "2023-07-06 23:59:59"
"<=today" Before today2) NULL "2023-07-07 23:59:59"
"<+today" Alias of "<=today" NULL "2023-07-07 23:59:59"
"-today" Alias of "<=today" NULL "2023-07-07 23:59:59"
"<yesterday" Before yesterday1) NULL "2023-07-05 23:59:59"
"<=yesterday" Before yesterday2) NULL "2023-07-06 23:59:59"
"<+yesterday" Alias of "<=yesterday" NULL "2023-07-06 23:59:59"
"-yesterday" Alias of "<=yesterday" NULL "2023-07-06 23:59:59"
"<2023-07-01" Before the given date1) NULL "2023-06-30 23:59:59"
"<=2023-07-01" Before the given date2) NULL "2023-07-01 23:59:59"
"<+2023-07-01" Alias of "<=2023-07-01" NULL "2023-07-01 23:59:59"
"-2023-07-01" Alias of "<=2023-07-01" NULL "2023-07-01 23:59:59"

Range parser (from|to)

Given format Description From ('Y-m-d H:i:s') To ('Y-m-d H:i:s')
"2023-07-01\|2023-07-03" Date range from "2023-07-01" to "2023-07-03" "2023-07-01 00:00:00" "2023-07-03 23:59:59"
"2023-07-01\|tomorrow" Date range from "2023-07-01" to "tomorrow" "2023-07-01 00:00:00" "2023-07-08 23:59:59"
"2023-07-01\|today" Date range from "2023-07-01" to "today" "2023-07-01 00:00:00" "2023-07-07 23:59:59"
"2023-07-01\|yesterday" Date range from "2023-07-01" to "yesterday" "2023-07-01 00:00:00" "2023-07-06 23:59:59"
"yesterday\|today" Date range from "yesterday" to "today" "2023-07-06 00:00:00" "2023-07-07 23:59:59"
"yesterday\|this-month" Date range from "yesterday" to last day of this month "2023-07-06 00:00:00" "2023-07-31 23:59:59"
"this-month\|today" Date range from first day this month to "today" "2023-07-01 00:00:00" "2023-07-07 23:59:59"

Infinitive range parser (NULL)

Given format Description From ('Y-m-d H:i:s') To ('Y-m-d H:i:s')
NULL No range given (infinitive range). NULL NULL

Methods

Class DateParser

method description type
->getDateRange(DateTimeZone\|string $dateTimeZone = null) Returns the range as DateRange class. DateRange
->formatFrom(string $format, DateTimeZone\|string $dateTimeZone = null) Returns the formatted "from" date. string
->formatTo(string $format, DateTimeZone\|string $dateTimeZone = null) Returns the formatted "to" date. string
->getFrom(DateTimeZone\|string $dateTimeZone = null) Returns the "from" date as DateTime object. DateTime\|null
->getTo(DateTimeZone\|string $dateTimeZone = null) Returns the "to" date as DateTime object. DateTime\|null
->getFromImmutable(DateTimeZone\|string $dateTimeZone = null) Returns the "from" date as DateTimeImmutable object. DateTimeImmutable\|null
->getToImmutable(DateTimeZone\|string $dateTimeZone = null) Returns the "to" date as DateTimeImmutable object. DateTimeImmutable\|null
->getDuration() Returns the duration from "from" to "to" in seconds. int\|null
->getDurationWithOwn() Returns the duration from "from" to "to" in seconds (including the first second). int\|null

Installation

Command line tool

Used to quickly check a given date time directly in the command line.

Supported timezones

See: src/Constants/Timezones.php

Development

License

This tool is licensed under the MIT License - see the LICENSE file for details


All versions of php-date-parser with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ixnode/php-naming-conventions Version ^0.1.1
adhocore/cli Version ^v1.0.0
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 ixnode/php-date-parser contains the following files

Loading the files please wait ....