lundi 5 février 2018

Time Date Calculation Wrong output

i am using laravel 5.5 trying to calculate days and multiply with price

working fine when i select date from drop down but when i type date calculation doing wrong what's happening i don't know

here is my controller

$pick = Carbon::parse($request->input('pickdate'));
    $drop = Carbon::parse($request->input('dropdate'));

    $lengthday = $pick->diffInDays($drop, false);

    $ptime = str_replace([' '], '', $request->pickuptime);
    $dtime = str_replace([' '], '', $request->droptime);
    $picktime = Carbon::parse($ptime);
    $droptime = Carbon::parse($dtime);

    $lengthmin = $picktime->diffInMinutes($droptime, false);
    $car = Car::where('slug', $car)->firstorfail();

    $cprice = $car->price;
    if ($lengthmin >= '1') {
        $minprice = $car->price;
    }
    else
    {
        $minprice = '0';
    }
    $price = $cprice*$lengthday+$minprice;

    if ($price <= '0') {
        return back()->with('warning', 'Please Enter Valid Date & Time');
    }

here is my view

<div class="form-date-w3-agileits">
        <div class="form-agileits">
          <label>Pickup Date :</label>
        </div>
        <div class="form-agileits-2">
          <input type="date" name="pickupdate" style="width: 92%;
outline: none;
font-size: 0.9em;
padding: 13px 10px;
border: 1px solid #fff;
font-weight: 100;
-webkit-appearance: none;
margin-bottom: 1.4em;
background: rgba(0, 0, 0, 0.69);
font-family: 'Amaranth', sans-serif;
color: #bbb9b9;" required="">


        </div>  
        <div class="clear"> </div>            
      </div>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire