本文介紹了php中的時間計算(加10小時)?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
限時送ChatGPT賬號..
我有時間:
$today = time();
$date = date('h:i:s A', strtotime($today));
如果當(dāng)前時間是1:00:00 am",我如何再添加 10 個小時變成 11:00:00 am??
if the current time is "1:00:00 am", how do i add 10 more hours to become 11:00:00 am??
推薦答案
strtotime()
為您提供一個數(shù)字,以秒為單位表示時間.要增加它,請?zhí)砑幽砑??的相應(yīng)秒數(shù).10 小時 = 60*60*10 = 36000,所以...
strtotime()
gives you a number back that represents a time in seconds. To increment it, add the corresponding number of seconds you want to add. 10 hours = 60*60*10 = 36000, so...
$date = date('h:i:s A', strtotime($today)+36000); // $today is today date
我假設(shè)您在 $today 中有一個字符串時間 - 如果您只是使用當(dāng)前時間,則更簡單:
I had assumed you had a string time in $today - if you're just using the current time, even simpler:
$date = date('h:i:s A', time()+36000); // time() returns a time in seconds already
這篇關(guān)于php中的時間計算(加10小時)?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!