我只想計算時間戳的午夜值。例如,1461043742這是今天的時間戳,我想從中獲得午夜12點鐘時間戳值的時間戳。而這是明天的時間戳1461130928,我希望明天午夜12點鐘的時間戳值顯示。我該如何做到這一點,有沒有可能在PHP中實現這一點?從特定時間戳獲取午夜時間戳值
0
A
回答
-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));
相關問題
- 1. 獲取上週三午夜的unix時間戳
- 2. 計數不同的SQL,並在午夜時間戳與時間戳
- 3. 獲得,因爲特定的時間戳,因爲一個特定的時間戳說,自從20120801185856時間戳
- 4. 從PHP獲取時間戳
- 5. 從時間戳獲取本地時間
- 6. 使用awk將時間戳從午夜過渡到微秒
- 7. UTC時區的午夜與unix時間戳
- 8. 從服務器獲取的時間戳本地時間戳
- 9. 如何從postgres獲取時間戳作爲時間戳?
- 10. PHP如何從時間戳獲得日/時間的時間戳
- 11. 獲取時間戳在特定月份的時間戳數組的元素
- 12. 時間戳午夜毫秒轉換得到弄亂
- 13. SQL。呼叫午夜時間戳unix,無需手動輸入
- 14. PHP - 將午夜日期轉換爲時間戳
- 15. 計算前一個午夜的unix時間戳
- 16. 舍入時間戳到第二天的午夜
- 17. 使用DateTime計算UTC +0的午夜時間戳python 3.5
- 18. 從時間戳
- 19. 從時間戳
- 20. 轉換時間:分鐘上午/下午到unix時間戳
- 21. 在其他時區獲取當地時間午夜時間
- 22. 獲取時間戳rtp包
- 23. 獲取unix時間戳
- 24. 獲取未來時間戳
- 25. iOS獲取UTC時間戳
- 26. UTC時間從時間戳
- 27. lubridate轉換午夜時間戳返回不適用:如何填寫缺少的時間戳
- 28. 帶時區時間戳的時間戳
- 29. 提取時間戳
- 30. 獲取從時間戳偏秒差