Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rdiyto's avatar

Why do dates repeat after I change the date format on the view page?

I am inputting a date from a form that will be stored in the database. Then I want to change the date format to dd-mm-yyyy, but the date repeats on the table view page.

Here is my input code with date type:

<div class="form-group">
<label for="Tanggalterima">Tanggal Terima</label>
<input type="date" class="form-control" id="Tanggalterima" name="received_date" placeholder="Tanggal terima voucher" value="{{ $vouchers->received_date }}">
</div>

Here is the code I used to change the date format

<td>{{ date('d-m-Y', strtotime($data->received_date)) }}</td>

Screenshot: The date repeats after changing the date format. https://prnt.sc/QhHvIFREEWy-

This is my structure of database: https://prnt.sc/2V8zu5qHlyp7

0 likes
4 replies
tangtang's avatar

@rdiyto

to make sure the date value, can you show the sample data for this received_date ? you can do it in picture or text here.

your case seems like the date is not saved properly in this column received_date

tangtang's avatar
tangtang
Best Answer
Level 6

@rdiyto

the date show 01-01-1970 because the column received_date is null or no data.

if you don't want null value show 01-01-1970, you need do some logic check

this is for sample (using ternary)

<td>{{ $data->received_date ? date('d-m-Y', strtotime($data->received_date)) : '-' }}</td>

in the else or this - you can add other information like no received date

1 like

Please or to participate in this conversation.