org_heigl/pdo_timezone_helper

Helper for timezone-handling in databases

dev-master 2016-09-30 18:51 UTC

This package is auto-updated.

Last update: 2024-04-29 03:18:27 UTC


README

Build Status Coverage Status

A small library to ease handling of timezones with PDO

Usage

This lib provides a helper that creates database-specific code to get a UTC-datetime from a DateTime-Entry and a timezone entry in your table.

You can store your datetimes in the database with or without an offset but with a timezone and this helper will create a UTC-Datetime from it for comparisons

$helper = new PdoTimezoneHelper::create($pdoObject);
$helper->setTimezoneField($field);

echo sprintf(
    "SELECT * FROM table WHERE %1$s < '2016-12-31T23:59:59'",
    $helper->getUtcDateTime($dateTimeField);

Installation

This lib is best installed using composer:

composer require org_heigl/pdo_timezone_helper

References: