1

Undesirable output Undesirable output Desired display Desired display

Cannot set DB value for type = "time"

What is stored in the DB is 2:20
I want 2:20 on the edit screen

But as the picture comes out on the screen How can I set the DB time to ?
edit.blade.php

<input id="estimated_work_time" type="time" name="estimated_work_time">{{$param->estimated_work_time}}

But I didn't get the results I wanted

edit.blade.php

<label for="estimated_work_time">Estimated work time</label><br>
<input id="estimated_work_time" type="time" name="estimated_work_time" value="{{$param->estimated_work_time}}"><br>

What should I do other than value?

It is displayed on the source code

I tried this too, but I get this error

<input id="estimated_work_time" type="time" name="estimated_work_time">{!!date('h:i a',strtotime($param->estimated_work_time)) !!} <br>

The error was this
A non well formed numeric value encountered

su3158
  • 555
  • 1
  • 6
  • 25

2 Answers2

1

Alright here is what I've gathered,

Left side is chrome and in right side is Mozilla enter image description here

In both the cases you simply needs to pass the value to the input by default,so i think you can achieve your desired output just by placing value like this XX:XX | 02:30.

<input id="estimated_work_time" type="time" name="estimated_work_time" value="{{ date('h:i',strtotime($param->estimated_work_time)) }}">

Here is the test i make it to understand it better

<?php
   // If i run this
   echo date('h:i','2:30');
   // I will get this error PHP Notice:  A non well formed numeric value encountered


   // So first you need to convert your date or time string into the proper format
   echo date('h:i',strtotime('2:30'));
   // this will return output this : 02:30
?>
Vipertecpro
  • 3,056
  • 2
  • 24
  • 43
0

for type time value should be 2:35 AM if you want 2:20 use other type and some php script

  • To be more precise , this is how you create 12 hours format in php laravel `date('h:i:s a m/d/Y', strtotime($date))` so i think this `{!! date('h:i a',strtotime($param->estimated_work_time)) !!}` will work – Vipertecpro Aug 29 '19 at 08:46
  • I can't display it from DB yet – su3158 Aug 29 '19 at 08:46
  • i am not going to create 12 hours format, i thought its DB value is estimated time just like 35 hours i mean it is not time it is just subtraction of two different time is it right – Nurbek Boymurodov Aug 29 '19 at 08:53