0

whenever i try to fill in datetime field i get this error in red : The expire does not match the format Y-m-d\TH:i:s.How can i fix this? here is my code: validation rules

 'dis' => 'required|date_format:Y-m-d\TH:i:s',
            'expire' => 'required|date_format:Y-m-d\TH:i:s|after:dis',

this is my form

<div class="form-group row">
    <label class="col-form-label col-4">Date de réception</label>
    <div class="col-8">
        <input type="datetime-local" name="dis" value="{{ old('dis') }}" class="form-control @error('dis') is-invalid @enderror">
        @error('dis')
        <span class="invalid-feedback" role="alert">
            <strong>{{ $message }}</strong>
        </span>
        @enderror
    </div>
</div>

<div class="form-group row">
    <label class="col-form-label col-4">Date d'expiration</label>
    <div class="col-8">
        <input type="datetime-local" name="expire" value="{{ old('expire') }}" class="form-control @error('expire') is-invalid @enderror">
        @error('expire')
        <span class="invalid-feedback" role="alert">
            <strong>{{ $message }}</strong>
        </span>
        @enderror
    </div>
</div>

the error

idchi
  • 761
  • 1
  • 5
  • 15
  • Change your date formats `date_format:Y-m-d\TH:i:s` to match your JS datepicker's date format. – bassxzero May 13 '23 at 14:22
  • A `datetime-local` input does not include seconds in its value. Its default value format is [`YYYY-MM-DDThh:mm`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local#handling_browser_support) or, in PHP format, `Y-m-d\TH:i`. – rickdenhaan May 13 '23 at 19:24

0 Answers0