get start time of yesterday in unix time stamp(php)

1.7k Views Asked by At

How i can get yesterday time in Unix time stamp format ?

I want to get start time of yesterday for example :

2016:12:25 00:00:00

2

There are 2 best solutions below

1
On BEST ANSWER

This will get you yesterday's timestemp

For yesterday date

echo "Yesterday date".time() - 86400; //this will take current time

For last day from given day

$inputedDate = "2016:12:25 00:00:00"; // you can pass date you want
$yesterdayDate = date ("Y-m-d H:i:s",strtotime($inputedDate)-86400);
echo $yesterdayDate;
2
On

You just subtract it by 1 day by passing strtotime('-1 day', strtotime('datetime')) to your date() function after your format

echo date( 'U', strtotime('-1 day', strtotime('2016:12:25 00:00:00')) );

DEMO