Reputation: 133
I stored my data at the database as Time Format, like '00:02:12'. then sum all the data:
foreach($pay_pending as $pending){
$total_pay_pending += strtotime($pending->points_request);
}
and return it:
return response()->json(['status'=> 'Success', 'Cashout_pending' => $total_pay_pending], 200);
it returns me an int value. The output is
{
"status": "Success",
"Cashout_pending": 6073229120
}
but I need it time format. please, can anyone help me...?AS
Upvotes: 1
Views: 29
Reputation: 9853
First change your add
logic to :
$total_pay_pending = 0;
foreach($pay_pending as $pending){
$total_pay_pending += strtotime($pending->points_request)-strtotime("00:00:00");
}
And then return
like -
{
"status": "Success",
"Cashout_pending": date("H:i:s",strtotime("00:00:00")+$total_pay_pending);
}
Upvotes: 1
Reputation: 392
Change your code: (date formatting of timestamp)
'Cashout_pending' => $total_pay_pending
to
'Cashout_pending' => date('H:i:s', $total_pay_pending)
Upvotes: 1
Reputation: 7489
You can use date
function to format it
return response()->json([
'status'=>'Success',
'Cashout_pending' => date('d M Y H:i:s',$total_pay_pending)
], 200);
Upvotes: 1