我正在嘗試使用以下方法獲取 -24 小時前的時間:$a = date('Y-m-d H:i:s', strtotime('-1 day', strtotime(date("Y-m-d H:i:s"))));
$a = strtotime($a);計算得很好,但是當我使用變量$a發送到 API 時,它說該值不是整數。返回的錯誤是:400 Invalid 'Query' parameter: json: cannot unmarshal number into Go struct field SearchClause.ClauseChildren.RuleValue of type string如果我將變量更改為 this:$a = '1583751712';并將其發送到 API,它絕對可以正常工作。
1 回答

素胚勾勒不出你
TA貢獻1827條經驗 獲得超9個贊
發生錯誤是因為您API
需要 astring
而不是integer
. 該函數strtotime
返回timestamp as integer
. 嘗試將typecast
您的整數轉換為字符串。如前所述Sherif
,如果您只需要返回時間戳,則不需要日期格式。
$a = (string) strtotime('-1 day');
- 1 回答
- 0 關注
- 82 瀏覽
添加回答
舉報
0/150
提交
取消