-2

Hello i have this code:

  <div class="text-center m-2">
                <label for="startdateReceived">Start Date</label>
                <input type="date" name="startdateReceived" id="startDateReceive"
                       value="{{date("Y-m-d", strtotime('monday this week'))}}"/>
                <label for="enddateReceive">End Date</label>
                <input type="date" name="enddateReceive" id="endDateReceive"
                       value="{{date("Y-m-d", strtotime('sunday this week'))}}"/>
                <button type="submit" id="receiveButton" onclick="getCashReceivedData()">Shfaq vlerat</button>
            </div>

On firefox this code works and shows the date 03/04/2023 while on Chrome it shows 04/03/2023 Is there a way to change the format on chrome?

Firefox date result:

enter image description here

Chrome date result:

enter image description here

miken32
  • 42,008
  • 16
  • 111
  • 154
laraCoder
  • 261
  • 15

1 Answers1

0

For the date type input, the displayed date is formatted based on the locale of the user's browser.

If you want to display a formatted date as you please, you can consider to use a javascript third party library, such as jquery-ui

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>jQuery UI Datepicker - Default functionality</title>
  <link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
  <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
  <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#datepicker" ).datepicker();
  } );
  </script>
</head>
<body>
 
<p>Date: <input type="text" id="datepicker"></p>
 
 
</body>
</html>
Khang Tran
  • 2,015
  • 3
  • 7
  • 10