How to set input type date's default value to today?

后端 未结 30 3023
刺人心
刺人心 2020-11-22 14:00

The HTML5 input types are great, Opera\'s new built-in date picker is a breeze, and Chrome has at least supported the new input type with a spin-wheel implementation.

<
30条回答
  •  忘了有多久
    2020-11-22 14:14

    And for those using ASP VBScript

    <%
    'Generates date in yyyy-mm-dd format
    Function GetFormattedDate(setDate)
    strDate = CDate(setDate)
    strDay = DatePart("d", strDate)
    strMonth = DatePart("m", strDate)
    strYear = DatePart("yyyy", strDate)
    If strDay < 10 Then
      strDay = "0" & strDay
    End If
    If strMonth < 10 Then
      strMonth = "0" & strMonth
    End If
    GetFormattedDate = strYear & "-" & strMonth & "-" & strDay
    End Function
    %>
    

    And then in the body, your element should look something like this

    
    

    Cheers!

提交回复
热议问题