Closed danielhr2001 closed 1 year ago
Because its an object and an object should implements __toString() function to format correctly in direct json marshalling
thanks it works:
$account_histories = AccountHistory::where('user_id', Auth::id())->with('accountCategory')->get();
foreach ($account_histories as $account_history) {
$account_history->expire_date = Jalalian::forge($expire_date)->__toString();
return $account_histories;
and the result:
[
{
"id": 1,
"expire_date": "1401-12-08 20:22:12",
something...
"account_category": {
something...
}
},
{
"id": 2,
"expire_date": "1401-12-08 20:23:17",
something...
"account_category": {
something...
}
}
]
آقا دمتگرم کار کرد. انتظار نداشتم جواب یک issu برای پکیج ایرانی اینقدر سریع پاسخ داده بشه. واقعا دمتگرم یک تنه داری کار رو جلو میاری.
I want to convert $expire_date to Jalali date like this:
but I got this response: reponse:
but when I return
return $account_history->expire_date
directly, I take correct data1402-12-03 00:00:00