<?php
/* - - - - - - - - - - - - - - - - - - -
DateTime class methods
- - - - - - - - - - - - - - - - - - - */
if(class_exists("DateTime"))
{
$dtm_mthd_DT = (array)get_class_methods("DateTime");
echo '<br>DateTime methods<br><br>';
foreach($dtm_mthd_DT as $kDT => $vDT)
echo "$kDT => $vDT<br>";
}
else
{
echo "The class DateTime does not exists!<br>";
}
echo '<br>';
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DateTimeImmutable class methods
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
if(class_exists("DateTimeImmutable"))
{
$dtm_mthi_DTI = (array)get_class_methods("DateTimeImmutable");
echo '<br>DateTimeImmutable methods<br><br>';
foreach($dtm_mthi_DTI as $kDTI => $vDTI)
echo "$kDTI => $vDTI<br>";
}
else
{
echo "The class DateTimeImmutable does not exists!<br>";
}
echo '<br>';
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DateTimeInterface class methods
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
if(class_exists("DateTimeInterface"))
{
$dtm_mthin_DTN = (array)get_class_methods("DateTimeInterface");
echo '<br>DateTimeInterface methods<br><br>';
foreach($dtm_mthin_DTN as $kDTN => $vDTN)
echo "$kDTN => $vDTN<br>";
}
else
{
echo "The class DateTimeInterface does not exists!<br><br>DateTimeInterface is meant so that
both DateTime and DateTimeImmutable can be type hinted for.<br><br>It is not possible to implement
this interface with userland classes.";
}
echo '<br>';
/* - - - - - - - - - - - - - - - - - - -
DateTimeZone methods
- - - - - - - - - - - - - - - - - - - */
if(class_exists("DateTimeZone"))
{
$arr_meth_DTZ = (array)get_class_methods("DateTimeZone");
echo '<br>DateTimeZone methods<br><br>';
foreach($arr_meth_DTZ as $kDTZ => $vDTZ)
echo "$kDTZ => $vDTZ<br>";
}
else
{
echo "The class DateTimeZone does not exists!<br>";
}
echo '<br>';
/* - - - - - - - - - - - - - - - - - - -
DateInterval methods
- - - - - - - - - - - - - - - - - - - */
if(class_exists("DateInterval"))
{
$arr_meth_I = (array)get_class_methods("DateInterval");
echo 'DateInterval methods<br><br>';
foreach($arr_meth_I as $kI => $vI)
echo "$kI => $vI<br>";
}
else
{
echo "The class DateInterval does not exists!<br>";
}
echo '<br>';
/* - - - - - - - - - - - - - - - - - - -
DatePeriod methods
- - - - - - - - - - - - - - - - - - - */
if(class_exists("DatePeriod"))
{
$arr_meth_P = (array)get_class_methods("DatePeriod");
echo 'DatePeriod methods<br><br>';
foreach($arr_meth_P as $kP => $vP)
echo "$kP => $vP<br>";
}
else
{
echo "The class DatePeriod does not exists!<br>";
}
?>
<?php
$dtm_01 = new DateTime("UTC");
$dtm_02 = new DateTime("America/Los_Angeles");
$dtz = new DateTimeZone("America/Sao_Paulo");
echo 'public __construct<br>';
$dtm_01->__construct("now", $dtz);
echo '$dtm_01->__construct("now", $dtz)';
echo '<br><br>public string format<br>';
$dtm_stf = $dtm_01->format(DATE_W3C);
echo $dtm_stf;
echo '<br><br>public static array getLastErrors<br>';
$dtm_01_LE = $dtm_01->getLastErrors();
print_r($dtm_01_LE);
echo '<br><br>public int getOffset<br>';
$dtm_01_Os = $dtm_01->getOffset();
echo $dtm_01_Os;
echo '<br><br>public int getTimestamp<br>';
$dtm_01_Ts = $dtm_01->getTimestamp();
echo $dtm_01_Ts;
?>
<?php
$dtt = new DateTime("UTC");
$dtz = new DateTimeZone("America/New_York");
$dtz->__construct("Africa/Cairo");
echo 'getLocation<br>';
$dtz_loc = $dtz->getLocation();
echo '<pre>';
print_r( $dtz_loc );
echo '</pre><br>getName<br>';
echo $dtz->getName();
echo '<br><br><br>getOffset<br>';
echo $dtz->getOffset($dtt);
echo '<br><br><br>getTransitions<br>';
$dtz_trans1 = $dtz->getTransitions();
echo '<pre>';
print_r( $dtz_trans1 );
echo '</pre><br>';
$dtz_trans2 = $dtz->getTransitions(1332753178, 1332796243);
echo '<pre>';
print_r( $dtz_trans2 );
echo '</pre><br>listAbbreviations<br>';
$dtz_Abbr = $dtz->listAbbreviations();
echo '<pre>';
print_r( $dtz_Abbr );
echo '</pre><br>listIdentifiers<br>';
$dtz_Ident = $dtz->listIdentifiers(DateTimeZone::AFRICA, NULL);
echo '<pre>';
print_r( $dtz_Ident );
echo '</pre><br><br>';
?>
<?php
$dtm_01 = new DateTime("UTC");
$dtm_02 = new DateTime("America/Los_Angeles");
echo '<br>public DateTime add<br>';
$dti = new DateInterval('P4Y3M20D');
// P = Period 4Y = 4 years 3M = 3 months 20D = 20 days
$dtm_01_add = $dtm_01->add($dti);
echo 'WARNING: This will be the new date value:<br><br>';
foreach($dtm_01_add as $dtm01 => $dt01)
{
echo $dtm01 . ' = ' . $dt01 . '<br>';
}
echo '<br><br>public DateTime sub<br>';
$nw_dti = new Dateinterval('P3Y2M10D');
// P = Period 3Y = 3 years 2M = 2 months 10D = 10 days
$dtm_01_sub = $dtm_01->sub($nw_dti);
echo 'WARNING: This will be the new date value:<br><br>';
foreach($dtm_01_sub as $nwdtm01 => $nwdt01)
{
echo $nwdtm01 . ' = ' . $nwdt01 . '<br>';
}
echo '<br>public DateInterval diff<br>';
$dtm_01_diff = $dtm_01->diff($dtm_02, false);
foreach($dtm_01_diff as $dfm01 => $dft01)
{
echo $dfm01 . ' = ' . $dft01 . '<br>';
}
echo '<br><br>';
$dtm_02_diff = $dtm_01->diff($dtm_02, true);
// (4 years 3 months 20 days) - (3 years 2 months 10 days) = 406 days
foreach($dtm_02_diff as $dfm02 => $dft02)
{
echo $dfm02 . ' = ' . $dft02 . '<br>';
}
?>
<?php
date_default_timezone_set("UTC");
$edate011 = new DateTime("now");
$intrv011 = new DateInterval('P2D');
// P = Period, 2D = 2 days
echo $edate011->format(DATE_W3C) . '<br><br>';
$edate011->add($intrv011);
echo $edate011->format(DATE_W3C);
echo '<br>Offset = ' . $edate011->GetOffSet();
echo '<br>timestamp = ' . $edate011->getTimestamp() . '<br>';
foreach($edate011->getTimezone() as $gtz011 => $tz011)
{
echo $gtz011 .' = ' . $tz011 . '<br>';
}
echo 'Year = ' . $edate011->format('Y') . '<br>';
echo 'Month = ' . $edate011->format('m') . '<br>';
echo 'Day = ' . $edate011->format('d') . '<br><br>';
echo 'hour = ' . $edate011->format('h') . '<br>';
echo 'min = ' . $edate011->format('i') . '<br>';
echo 's = ' . $edate011->format('s') . '<br><br>';
var_dump($edate011->getTimeZone());
echo '<br><br>';
?>
<?php
echo 'PHP ' . phpversion() . '<br><br>';
// DECLARED INTERFACES
foreach(get_declared_interfaces() as $dcint => $decl)
{
echo $dcint . ' = ' . $decl . '<br>';
}
echo '<br>';
?>
<?php
echo 'PHP ' . phpversion() . '<br><br>';
// DECLARED CLASSES
foreach(get_declared_classes() as $declass => $decl)
{
echo $declass . ' = ' . $decl . '<br>';
}
?>
<?php
date_default_timezone_set("America/New_York");
$dftz021 = date_default_timezone_get();
$arrdc02 = new DateTime("now");
$arrd02 = get_object_vars($arrdc02);
print_r($arrd02);
echo '<br><br>';
?>
<?php
date_default_timezone_set("America/New_York");
$dtm_01 = new DateTime("America/New_York");
$dtm_02 = new DateTime("America/New_York");
echo '<br>public DateTime add<br>';
$dtib = new DateInterval('PT2H2M2S');
$arrdth = get_object_vars($dtib);
$dtm_01_add = $dtm_01->add($dtib);
echo '<br>';
foreach((array)$dtm_01->add($dtib) as $dtm01a => $dt01a)
{
echo $dtm01a . ' = ' . $dt01a . '<br>';
}
echo '<br><br>public DateTime sub<br>';
$nw_dti = new Dateinterval('P1Y2M10D');
$arrdti = get_object_vars($nw_dti);
$dtm_01_sub = $dtm_01->sub($nw_dti);
echo '<br>';
foreach((array)$dtm_01->sub($nw_dti) as $dtm01b => $dt01b)
{
echo $dtm01b . ' = ' . $dt01b . '<br>';
}
echo '<br><br>public DateInterval diff<br><br>';
$dtm_01_diff = $dtm_01->diff($dtm_02, false);
foreach($dtm_01_diff as $dtm01b => $dt01b)
{
echo $dtm01b . ' = ' . $dt01b . '<br>';
}
echo '<br>';
print_r($dtm_01_diff);
echo '<br><br>';
$dtm_02_diff = $dtm_01->diff($dtm_02, true);
foreach($dtm_02_diff as $dtm01c => $dt01c)
{
echo $dtm01c . ' = ' . $dt01c . '<br>';
}
echo '<br>';
print_r($dtm_02_diff);
?>
<?php
$tz10 = date_default_timezone_set("America/Los_Angeles");
$arrdc10 = new DateTime("now");
$add10 = new DateInterval('P3W');
$arrdc10->add($add10);
$arrdth = get_object_vars($arrdc10);
print_r($arrdth);
/*
echo $arrdth['date'] . '<br>' . $arrdth['timezone'];
echo '<br><br>';
*/
?>