Python de fecha y hora
from datetime import datetime as d
date = d.now()
print(date.strftime("%Y-%m-%d %H:%M:%S"))
Majid Peidaei
from datetime import datetime as d
date = d.now()
print(date.strftime("%Y-%m-%d %H:%M:%S"))
import datetime
x = datetime.datetime(2018, 9, 15)
print(x.strftime("%b %d %Y %H:%M:%S"))
DateTime date = DateTime.Now.AddHours(26);
DateTime dateNow19 = new DateTime(date.Year, date.Month, date.Day, 19, 00, 00);
DateTime dateNow08 = new DateTime(date.Year, date.Month, date.Day, 08, 00, 00);
Console.WriteLine(date);
Console.WriteLine(dateNow19);
Console.WriteLine(dateNow08);
if (date < dateNow19 && date > dateNow08)
{
Console.WriteLine("Success19");
}
else
{
Console.WriteLine("False");
}
//first day and last day of month
DateTime date = ...
var firstDayOfMonth = new DateTime(date.Year, date.Month, 1);
var lastDayOfMonth = firstDayOfMonth.AddMonths(1).AddDays(-1);
<?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