How to get an hour ago in PHP

This example shows you how to get an hour ago in PHP using date and strtotime combination.

DateTimeExample.php
<?php

$date = date('Y-m-d H:i:s', strtotime('-1 hour'));

echo $date;
echo '<br>';
echo strtotime($date);  // timestamp

Output:

2017-11-30 03:24:34
1512012274

guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x