DateTime and Timestamps 1

DateTime and Timestamps

$dateTime = new DateTime('2016-05-20');
echo $dateTime->getTimestamp();

# Output: 1271802325

Here is what the above code is Doing:
1. We create a new DateTime object with the date 2016-05-20.
2. We call the getTimestamp() method on the DateTime object.
3. The getTimestamp() method returns the Unix timestamp for the date 2016-05-20.

Similar Posts