2017-10-17 49 views
-2

我有這個日期和時間,我只想得到毫秒,直到每個凌晨2點。 示例日期/時間:10-18-2017 00:00:00 - 凌晨2點前2小時,凌晨2點前的毫秒爲7200000.我現在將如何獲得毫秒數據與日期明天

我該怎麼做或應該使用什麼方法。在此先感謝

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

沒有人可以幫我的傷心 –

+2

可能的複製[如何獲得在PHP毫秒當前時間?(https://stackoverflow.com/questions/3656713/how-to -get-電流 - 時間 - 在-毫秒功能於PHP) – Mat

回答

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);