2016-04-19 12 views
0

タイムスタンプの真夜中値を計算したいだけです。たとえば、1461043742これは今日のタイムスタンプです。私は時計のタイムスタンプ値の12時12分の深夜のタイムスタンプが必要です。そしてこれは明日のタイムスタンプ1461130928です。私は明日の深夜12時計のタイムスタンプ値を表示したいです。どうしたらいいですか?PHPでこれを実現する可能性はありますか?特定のタイムスタンプから真夜中のタイムスタンプ値を取得する

答えて

-1

あなたは深夜の時間に時間と分を変更する必要があるのstrtotime

$date = '2016-04-18 00:00:00'; 
$timestamp = strtotime($date); 

$date = date('Y-m-d 00:00:00'); 
$timestamp = strtotime($date); 
0

を使用することができます。

$date = new DateTime() // By default gets the current time 
$date.setTime(0,0,0) // Midnight hour 
$stamp = date.getTimestamp() 
0

あなたはstrtotimeを使用することができます。

// Input: 
$now = 1461043742; 

// Calculate: 
$midnight = strtotime("midnight", $now); 
$midnight_tomorrow = strtotime("midnight tomorrow", $now); 

// Test 
print(date('c', $midnight)); 
print(date('c', $midnight_tomorrow)); 
関連する問題