-2

i have this date and time i just want to get the millisecond until every 2:00 am. example date/time: 10-18-2017 00:00:00 -- 2 hours before 2 am the millisecond before 2:00 am is 7200000.

what should i do or what method should i use. Thanks in advance

$datetimenow = date("m-d-Y H:i:s", strtotime('+0 hours'));

1 Answers1

0
$TwoAMDay = time();

// add one day if next 2am is tomorrow
if(date('H', $TwoAMDay) >= 2) {
    $TwoAMDay = $TwoAMDay + 86400;
}

$twoAMDate = date('Y-m-d 02:00:00', $TwoAMDay);
$twoAMTime = strtotime($twoAMDate);

$differenceMilliseconds = (1000 * $twoAMTime) - round(microtime(true) * 1000);
LKKP4ThX
  • 236
  • 2
  • 6