datetime timestamp code example
Example 1: timestamp python
from datetime import datetime
# current date and time
now = datetime.now()
timestamp = datetime.timestamp(now)
print("timestamp =", timestamp)
Example 2: datetime python
from datetime import datetime as d
date = d.now()
print(date.strftime("%Y-%m-%d %H:%M:%S"))
Example 3: DateTime and Timestamps
$dateTime = new DateTime('2016-05-20');
echo $dateTime->getTimestamp();
# Output: 1271802325
Example 4: python datetime from timestamp utc
dt_object = datetime.fromtimestamp(timestamp)