import datetime
x = datetime.datetime(2018, 9, 15)
print(x.strftime("%b %d %Y %H:%M:%S"))
<?php
$deliverytime = new DateTime('2014-09-08 06:00:00');
$hour = $deliverytime->format('H');
if ($hour < 12) {
echo "Morning";
} else {
echo "Afternoon or evening";
}
?>
dateutil - powerful extensions to datetime
pip install python-dateutils