mardi 23 mai 2023

Laravel date changes to 1st January 1970 when passed from blade template to model in a function call

I have a larav`el project where I produce balance sheet by getting ledger opening balance and aggregating transactions that occurs between two dates say 01/01/2023 to 31-03-2023.

The controller fetches all ledger transactions between start_date and end_date as requested by the user. It forward the records and the two dates to a blade file.

Shown below is the code segment within the blade file where a call a method in a model

***<?php dd($start_date, $end_date); ?>***
<td></t`d>
<td>
<?php  $currYrResult = **$ppe->getBalance($start_date, $end_date, null, true)** ?>
<?php  $currPpeTotal = bcsub($currYrResult['balance'], $curr_accum_depreciation['ppeTotal'], 2) ?>
........
</td> 

From within the blade code shown above, I call a Model method using $ppe->getBalance($start_date, "yes", null, true) passing the two dates but in the model method the end_date is 1970-01-01 instead of 2023-03-31 passed from the blade

the above statement in the blade file prints 2023-01-01 and 2023-03-31

but in the method getBalance, when I prints the date as shown in the code segment below, I get 2023-01-01 and 1970-01-01

public function getBalance($start_date = null, $end_date = null, $year = null, $accumulate = null)    {
*dd($start_date, $end_date);*
$dr_total = $this->getDebitBalance($start_date, $end_date, $year, $accumulate);
$cr_total = $this->getCreditBalance($start_date, $end_date, $year, $accumulate);

Please your assistance will be appreciated

I tried using createDateFromFormat to no avail. When I pass end_date as value instead of variable I get same issue



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/ZSwEDT2
via IFTTT

Aucun commentaire:

Enregistrer un commentaire