2016-03-10 31 views

回答

1

的strtotime()或許可以做到這一點:

$api_time = some_api_call(); 

$timestamp = strtotime("today $api_time"); 

if ($timestamp < (time()-60)) { 
    $timestamp = strtotime("tomorrow $api_time"); 
} 
+0

你的'strtotime'不能正常工作,你需要用'today'移動'$ api_time'(這個問題中的「19:33」)。它應該是'$ timestamp = strtotime(「今天$ api_time」);'雖然很優雅的答案。 ^^編輯:另外需要更改另一個''timestamp = strtotime(「明天$ api_time」);' – Jon

+0

是的,看起來我沒有驗證返回時間戳的確切值。固定...謝謝。 :) –

相關問題