Web Analytics Made Easy -
StatCounter Where does html 5 get its default date format from - CodingForum

Announcement

Collapse
No announcement yet.

Where does html 5 get its default date format from

Collapse
This topic has been answered.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Where does html 5 get its default date format from

    Hi,

    i have some html like so.

    HTML Code:
     <tr>
                <td class="goog_date_text">Select Dates (google date format is DDMMYYYY)</td>
                <td class="goog_date"><label for="goog_startdate">Choose Date: </label><input type="date" name="goog_startdate"  value="01/01/2023"></td>
                <td class="goog_date"><label for="goog_enddate">Choose Date: </label><input type="date" name="goog_enddate"  value="06/01/2023"></td>
                </tr>
    as you can see i have set the default value, however the page shows MM/DD/YYYY

    I should be able to set the default date to what i want, correct?

    Click image for larger version

Name:	datessample.jpg
Views:	65
Size:	21.2 KB
ID:	2436794
    Last edited by durangod; Jul 10, 2023, 09:30 PM.
    I am not crazy, my computer had me checked but its on dialup and im still waiting for results :)
    A good way to remember objects from arrays is you shoot objects with arrows Example: $name->id; then Arrays are $name['id'];
    durangod is short for durango dave
  • Answer selected by durangod at Jul 11, 2023, 06:50 AM.

    The date value must be in the form YYYY-MM-DD. It will then be presented according to the user’s browser’s localization settings. See also: https://developer.mozilla.org/en-US/...d_time_formats

    Comment


    • #2
      The date value must be in the form YYYY-MM-DD. It will then be presented according to the user’s browser’s localization settings. See also: https://developer.mozilla.org/en-US/...d_time_formats
      Stop solving problems you don’t yet have!

      Comment


      • #3
        Great thanks, and thanks for the link as well.
        I am not crazy, my computer had me checked but its on dialup and im still waiting for results :)
        A good way to remember objects from arrays is you shoot objects with arrows Example: $name->id; then Arrays are $name['id'];
        durangod is short for durango dave

        Comment


        • #4


          Yes, you're correct that you should be able to set the default date to the format you want. However, the date format used in HTML's input element with the type="date" attribute is based on the user's browser and operating system settings. It's not directly controllable through HTML or CSS.

          When you set the value attribute of the input element, you should use the standard ISO date format "YYYY-MM-DD" for compatibility across different browsers. For example:

          <tr>
          <td class="goog_date_text">Select Dates (google date format is DDMMYYYY)</td>
          <td class="goog_date"><label for="goog_startdate">Choose Date: </label>
          <input type="date" name="goog_startdate" value="2023-01-01"></td>
          <td class="goog_date"><label for="goog_enddate">Choose Date: </label><
          input type="date" name="goog_enddate" value="2023-01-06"></td>
          </tr>

          This will set the default date to January 1, 2023, and January 6, 2023, respectively, following the "YYYY-MM-DD" format. However, the way this date is displayed in the input field will still depend on the browser's settings. Some browsers may display it as "MM/DD/YYYY" or "DD/MM/YYYY" based on the user's locale.

          If you want to have more control over the date format, you might need to use JavaScript to handle the formatting and parsing of dates according to your specific requirements.
          Vipul Gupta
          Senior Consultant
          Taazaa Inc, Custom Software Development Company

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎