locked
display date issue with edge and firefox RRS feed

  • Question

  • User322196286 posted

    I am having trouble getting the date to display in an input field.  It looks like Edge wants the date in yyyy-mm-dd format before it will show the date.  Firefox works.  I have tried both classic asp and asp.net and I can't get it to work in both browsers.

    asp:
    <div>CO Date: <input type="date" name="codate" value = "<%=CDate(date())%>" title = "coDate"></div>
    
    asp.net:
    <div>CO Date: <input type="date" name="codate" value = "<%=DateTime.Today.ToShortDateString()%>" title = "coDate"></div>

    Both of the code segments above will display the date 3/2/2017 in firefox but not in edge.  If I use:

    <div>CO Date: <input type="date" name="codate" value = "<%=DateTime.Now.ToString("yyyy-MM-dd")%>" title = "coDate"></div>

    then Edge displays the date 3/2/2017 but firefox shows 2017-03-02.
     
    However if I use:

    <div>CO Date: <input type="date-local" name="codate" value = "<%=CDate(date())%>" title = "coDate"></div>

    then both Firefox and Edge show the date as: 3/2/2017 but date-local is not proper html5.  How can I get this work in both browsers and use proper syntax?  asp.net is preferred.

    Thursday, March 2, 2017 9:30 PM

All replies