Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get timestamp of today and yesterday in php

Tags:

php

timestamp

How can I get the timestamp of 12 o'clock of today, yesterday and the day before yesterday by using strtotime() function in php?

12 o'clock is a variable and would be changed by user.

like image 652
hd. Avatar asked Jan 24 '11 09:01

hd.


People also ask

How to get previous date from given date in php?

php $date = isset($_GET['date']) ? $_GET['date'] : date('Y-m-d'); $prev_date = date('Y-m-d', strtotime($date . ' -1 day')); echo $prev_date; ?>


1 Answers

$hour = 12;  $today              = strtotime($hour . ':00:00'); $yesterday          = strtotime('-1 day', $today); $dayBeforeYesterday = strtotime('-1 day', $yesterday); 
like image 91
deceze Avatar answered Sep 18 '22 19:09

deceze