Level 47
Something like moment should do what you need it to do: https://momentjs.com/docs/#/displaying/
$("input[name='date']").val(moment(data.date).format('DD MMMM YYYY - HH:mm'));
That should be the equivalent format for moment.
2 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Im using cabon to show in a form field a date in this format "format('d F Y - H:i')":
<div class="input-group date" data-provide="datepicker">
<input type='text' name="date" value="{{ $post->date->format('d F Y - H:i') }}"
class="form-control" placeholder="DD/MM/YYY" />
<span class="input-group-addon"><i class="fa fa-calendar text-primary" aria-hidden="true"></i></span>
</div>
Then I have some js to add some values to the form fields. My doubt is if we can use also "format('d F Y - H:i')" in the data array like below? The variable data is an array returned by the controller o the view.
JS
$("input[name='date']").val(data.date.format('d F Y - H:i'));
Something like moment should do what you need it to do: https://momentjs.com/docs/#/displaying/
$("input[name='date']").val(moment(data.date).format('DD MMMM YYYY - HH:mm'));
That should be the equivalent format for moment.
Please or to participate in this conversation.