ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:datetime:custom_dst

This is an old revision of the document!


Daylight Savings Time

Syntax
void adodb_daylight_sv(
      array &$dateStructure,
       bool $isGmt
      )

Currently, the ADOdb date/time library has no built-in support for Daylight Savings Tme, but provides a simple hook that allows you to define your own daylights savings function. The function must be called adodb_daylight_sv(), and must be accessible in the current procedure.


Usage

In this example, we apply daylights savings in June or July, adding one hour. This is extremely unrealistic as it does not take into account time-zone, geographic location, current year.

function adodb_daylight_sv(&$dateStructure, $isGmt)
{
    if ($isGmt) 
        return;
    $m = $dateStructure['mon'];
    if ($m == 6 || $m == 7) 
        $dateStructure['hours'] += 1;
}

This is only called by adodb_date() and not by adodb_mktime().

The Date Structure

The format of $arr is

Array (
 [seconds] => 0
 [minutes] => 0
 [hours] => 0
 [mday] => 1      # day of month, eg 1st day of the month
 [mon] => 2       # month (eg. Feb)
 [year] => 2102
 [yday] => 31     # days in current year
 [leap] =>        # true if leap year
 [ndays] => 28    # no of days in current month
 )
v5/datetime/custom_dst.1460683320.txt.gz · Last modified: 2017/04/21 11:26 (external edit)