Lê Gia Lễ Lê Gia Lễ - 1 year ago 88
PHP Question

Php mktime() return wrong value of hour,minute,second . How to fix?

I'm using

to get timestamp of the input date.
Here is my code:

` $dayFrom = $this->request->getPost('day-from');
$monthFrom = $this->request->getPost('month-from');
$yearFrom = $this->request->getPost('year-from');
$starttimestamp = mktime(0, 0, 0, $monthFrom, $dayFrom, $yearFrom);
$endtimestamp = mktime(23, 59, 59, $monthFrom, $dayFrom, $yearFrom);`

And when i get the result

$starttimestamp = 1469829600
$endtimestamp = 1469915999

i try to convert it back using http://www.epochconverter.com/ to check if it is correct but it show
7/30/2016, 5:00:00
start time
7/31/2016, 4:59:59 AM
end time

Why is there error with converting the hours, minutes and seconds in

Answer Source

First set the date_default_timezone_set, it may solve your warning and use this code to convert time stamp into readable time echo date('m/d/Y H:i:s', 1299446702);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download