Download the PHP package petrknap/zoned-datetime-persistence without Composer

On this page you can find all versions of the php package petrknap/zoned-datetime-persistence. 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 zoned-datetime-persistence

Timezone aware date-time persistence

GitHub JitPack Packagist

Many data storage systems (like MySQL) do not natively support storing timezone information alongside date-time values. This limitation introduces ambiguity when handling zoned date-times — particularly in applications operating across multiple timezones or even within a single timezone that observes multiple offsets (e.g. due to daylight saving time).

This package addresses the issue by providing tools that treat zoned date-time as a pair consisting of:

Implemented

UTC with local date-time

UtcWithLocal

The most useful approach is to store the UTC date-time together with its local counterpart. This dual representation enables seamless manipulation of date-time values directly within storage system. The local date-time is ideal for grouping and filtering based on user or business context, while the UTC value ensures consistent and accurate sorting across timezones.

How to use it

There is built-in support for the Jakarta Persistence API (see JpaTest.java), the Doctrine ORM (see DoctrineTest.php), the Eloquent (see EloquentTest.php), and, of course, it can be integrated manually into any project, giving you full flexibility to adapt it to your specific needs.

UTC with timezone

UtcWithTimezone

If you want to preserve the original timezone as is, you cannot use UtcWithLocal, because it works over fixed offsets. In this case, you need to use this implementation.

UTC with system timezone

UtcWithSystemTimezone

The most compact approach is to store only the UTC date-time. This serves as an alternative to MySQL's TIMESTAMP, Postgres's TIMESTAMP WITH TIMEZONE, and custom ORM types. It offers full range of DateTime, avoids normalization on connection, adds .utc into your queries for better readability and didn't need special configuration.

UTC date-time converter / type / cast

UtcDateTimeConverter Jakarta Persistence API

This converter transparently manages conversions of ZonedDateTime, including JPQL parameters. That means you no longer need to worry about manual timezone adjustments.

For examples, see the JpaTest.

UtcDateTimeType Doctrine ORM

In contrast to UtcDateTimeConverter, this type does not automatically adjust the timezone of DQL parameters. You must therefore provide the type when you are calling setParameter on your queries. Also, you have to register the type in your Doctrine configuration manually.

For examples, see the DoctrineTest.

AsUtcDateTime Eloquent

In contrast to UtcDateTimeConverter and UtcDateTimeType, this cast may or may not adjust the timezone of any input. You should therefore handle timezone conversions explicitly everytime you are providing date-time into Eloquent. But the conversion after hydration works well.

For examples, see the EloquentTest.


You can support this project via donation. The project is licensed under the terms of the LGPL-3.0-or-later.


All versions of zoned-datetime-persistence with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
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 petrknap/zoned-datetime-persistence contains the following files

Loading the files please wait ...