Home > Software design >  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

Time:01-03

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

CodePudding user response:

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.

  • Related