I have a problem in my code, it seems like PHP and Javascript is returning different Unix Epoch time..
My code in Javascript is this:
day = 13;
month = 4;
year = 2011;
hour = 15;
minute = 10;
date = new Date(year, month - 1, day, hour, minute, 0);
dateseconds = date.getTime();
The dateseconds returns 1302678600000
But in my PHP code I use this:
$day = 13;
$month = 4;
$year = 2011;
$hour = 15;
$minute = 10;
$date = mktime($hour, $minute, 0, $month - 1, $date, $year);
$dateseconds = date('U', $date);
The dateseconds in PHP returns smaller time: 1302678600
It's similar but it seems like Javascript returns bigger time..
How to make them similar?
Apparently Javascript returns the given time in milliseconds, while PHP gives seconds only.
Edit: so to answer your question, I think you should divide the time you get in JS by 1000, because it will always be divisible with 1000, since the smallest unit you set in your code example is in minutes.
javascript returns milliseconds, and php - seconds
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With