我正在使用 php/symfony 4 開發(fā)一個項目,在創(chuàng)建對象后,我發(fā)送推送通知,通常無需指定傳遞參數(shù)“send_after”,它工作正常,移動設(shè)備實時接收通知。但是當(dāng)我指定交付日期時,他們沒有考慮它,并且它是在創(chuàng)建我的對象時發(fā)送的,這是我的代碼片段:$fields = array( 'app_id' => $this->api_key, 'include_player_ids' => $devices, 'data' => array( "type" => $type, "url" => $url ), 'contents' => $content ); if (null != $dateTime) { date_time_set($dateTime, 9, 0, 0); array_push($fields, [ 'send_after' => $dateTime->format('Y-m-d H:i:s TO')] ); } $fields = json_encode($fields);所以我嘗試尊重文檔中提到的這種格式:“2015-09-24 14:00:00 GMT-0700”請問如果有人已經(jīng)遇到過這個問題,我該如何解決?
1 回答

慕尼黑的夜晚無繁華
TA貢獻1864條經(jīng)驗 獲得超6個贊
這應(yīng)該有效:
$fields = array(
'app_id' => $this->api_key,
'include_player_ids' => $devices,
'data' => array(
"type" => $type,
"url" => $url
),
'contents' => $content
);
/* $dateTime=date_create("2020-08-12"); */
if (null != $dateTime) {
date_time_set($dateTime, 9, 0, 0);
/* $send_after = date_format($dateTime,'Y-m-d H:i:s TO'); */
$fields['send_after'] = $dateTime->format('Y-m-d H:i:s TO')] ); /* $send_after */
}
$fields = json_encode($fields);
- 1 回答
- 0 關(guān)注
- 93 瀏覽
添加回答
舉報
0/150
提交
取消