0 レビュー
3 回答
php-特定のタイムスタンプから深夜のタイムスタンプ値を取得する
タイムスタンプの真夜中の値を計算したいだけです。たとえば、1461043742これは今日のタイムスタンプです。このタイムスタンプから、12時のタイムスタンプ値の真夜中のタイムスタンプが必要です。これは1461130928です。これから明日のタイムスタンプを表示します。明日の深夜12時のタイムスタンプ値を表示します。どうすればこれを行うことができますか、PHPでこれを達成する可能性はありますか?
わからない
0
レビュー
答え :
解決策:
strtotime
を使用できます:
//入力:
$ now = 1461043742;
//計算:
$ midnight = strtotime( "midnight"、$ now);
$ midnight_tomorrow = strtotime( "midnight tomorrow"、$ now);
// テスト
print(date('c'、$ midnight));
print(date('c'、$ midnight_tomorrow));
わからない
0
レビュー
答え :
解決策:
時間と分を深夜に変更する必要があります。
$date = new DateTime() // By default gets the current time
$date.setTime(0,0,0) // Midnight hour
$stamp = date.getTimestamp()
わからない
0
レビュー
答え :
解決策:
strtotimeを使用できます
$date = '2016-04-18 00:00:00';
$timestamp = strtotime($date);
$date = date('Y-m-d 00:00:00');
$timestamp = strtotime($date);
わからない
同様の質問
私たちのウェブサイトで同様の質問で答えを見つけてください。