How to get current date in 'YYYY-MM-DD' format in ASP.NET ?
Client Side Method to display Current Date and Time The ShowCurrentTime method makes an AJAX call to the server using ASP.Net AJAX ScriptManager PageMethods and executes the GetCurrentTime method which accepts the username and returns a string value.
DateTime dt2 = DateTime. ParseExact(date31strin, "MM-dd-yyyy HH:mm:ss", CultureInfo. InvariantCulture); the format is changed to "dd-MM-yyyy HH:mm:ss" .
It should be formatted like this: myDateTime. ToString("yyyy/MM/dd hh:mm:ss"); or myDateTime. ToString("yyyy/MM/dd); Because mm is for minute and for month MM should be used.
Which WebControl are you using? Did you try?
DateTime.Now.ToString("yyyy-MM-dd");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With