Date Time Function in PHP

<?php
$t=time();
echo($t . “<br>”);
echo(date(“Y-m-d”,$t));
?>

Calculate the difference between two dates:

<?php
$date1=date_create(“2013-03-15”);
$date2=date_create(“2013-12-12”);
$diff=date_diff($date1,$date2);
?>

Return a new DateTime object, and then format the date:

<?php
$date=date_create(“2013-03-15”);
echo date_format($date,“Y/m/d H:i:s”);
?>

Return a transition for a timezone:

<?php
$timezone = new DateTimeZone(“Europe/Paris”);
// Procedural style
print_r(reset(timezone_transitions_get($timezone)));

echo “<br><br>”

// Object oriented style
print_r(reset($timezone->getTransitions()));
?>

Format a local time/date as integer. Test all the different formats:

<?php
echo idate(“B”) . “<br>”;
echo idate(“d”) . “<br>”;
echo idate(“h”) . “<br>”;
echo idate(“H”) . “<br>”;
echo idate(“i”) . “<br>”;
echo idate(“I”) . “<br>”;
echo idate(“L”) . “<br>”;
echo idate(“m”) . “<br>”;
echo idate(“s”) . “<br>”;
echo idate(“t”) . “<br>”;
echo idate(“U”) . “<br>”;
echo idate(“w”) . “<br>”;
echo idate(“W”) . “<br>”;
echo idate(“y”) . “<br>”;
echo idate(“Y”) . “<br>”;
echo idate(“z”) . “<br>”;
echo idate(“Z”) . “<br>”;
?>