简体   繁体   中英

How to get client side html date from server side with yyyymmdd format

How to get client side html date from server side with yyyymmdd format.

Following html code is for capturing date.

<input type="date"  id="dtpdob" runat="server" placeholder="Enter Date of Birth" name="dtpdob"  />

Following server side code I am using to change the date format. But it is now working.

dim ddob as string=Format(dtpdob.Value, "yyyyMMdd")

Please help how can I change the date format

the format use you have ONLY works if the input is a date - and NOT a string.

So, you can cast the value to date - and then format can be used.

eg

    Dim ddob As String = Format(CDate(dtpdob.Value), "yyyyMMdd")

So format requires a date value, and if you feed format a string - it will not work.

And the "value" from that control is of course a string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM