0

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 Answers2

0

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;
Akshay
  • 700
  • 9
  • 23
0

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

Beginner
  • 4,118
  • 3
  • 17
  • 26
  • http://www.epochconverter.com/ it says : GMT: Fri, 23 Dec 2016 23:00:00 GMT – addadsa asddasdas Dec 26 '16 at 10:12
  • @addadsaasddasdas that converter is wrong see this https://gyazo.com/7773c2df60be4e152ef352e39c6b2830 https://gyazo.com/66c46e94b65341f4b2fc06d19a2451d2, you are passing different timestamp. not the timestamp came from my php fiddle – Beginner Dec 26 '16 at 11:36