Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Date and Time need to split

Here is what i'm getting when i fetch data from its database.

enter image description here

So that i want to split into 2 different column.can anyone help me here? Here is the view.

<table class="table table-striped">
    <thead>
        <th>Trainee ID</th>
        <th>Name with initials</th>
        <th>On time</th>
    </thead>

    <tbody>
        @foreach($items as $item)
            <tr>
                <td>{{ $item->trainee_id }}</td>
                <td>{{ $item->name }}</td>
                <td>{{ $item->time }}</td>
            </tr>
        @endforeach
    </tbody>
</table>
like image 906
Dasun Avatar asked Jan 31 '23 03:01

Dasun


1 Answers

<table class="table table-striped">
              <thead>
                <th>Trainee ID</th>
                <th>Name with initials</th>
                <th>On Date</th>
                <th>On Time</th>

              </thead>

              <tbody>
                @foreach($items as $item)
                <?php 
                  $temp = explode(' ',$item->time);
                ?>
                 <tr>

              <td>{{ $item->trainee_id }} </td>
              <td>{{ $item->name}}</td>
              <td>{{ $temp[0] }}</td>
              <td>{{ $temp[1] }}</td>

                </tr>

                @endforeach
              </tbody>

      </table>

try this

like image 160
Exprator Avatar answered Feb 03 '23 07:02

Exprator