php get date from datetime code example
Example 1: php get day from date
$timestamp = strtotime('2009-10-22');
$day = date('D', $timestamp);
var_dump($day);
Example 2: extract date from DateTime object php
<?php
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:s');
?>
Example 3: php extract time from datetime
$time = '2013-01-22 10:45:45';
echo $time = date("H:i:s",strtotime($time));
Example 4: php get date
date("Y-m-d h:i:sa")
Example 5: php code to display current date and time in different formats
echo date('Y.m.d H:i:s');