2014-04-07 52 views
0

我想28天增加爲日期和不斷收到以下錯誤:非合式數值遇到過,但所有的數字

Message: A non well formed numeric value encountered

我的代碼是:

$expirationDate = 1396885780; 

    $entryDate = 1396885780; 

    if ($expirationDate) { 
     $expiration = time(strtotime($expirationDate, '+28 day'));   
    } else { 
     $expiration = time(strtotime($entryDate, '+28 day'));   
    } 

所以基本上我傳遞了一個%U格式的日期(我認爲它是通用的)並且想要添加28天。

任何人都可以在這裏看到問題?

回答

1

參數2時調用strtotime()

The function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 UTC), relative to the timestamp given in now, or the current time if now is not supplied.

再有就是不需要調用時間(),試圖將其轉換成一個時間戳,因爲的strtotime()返回一個時間戳已經

$expirationDate = 1396885780; 

$entryDate = 1396885780; 

if ($expirationDate) { 
    $expiration = strtotime('+28 day', $expirationDate); 
} else { 
    $expiration = strtotime('+28 day', $entryDate); 
} 
相關問題