net 4 and c#.
I have in a Text Box DateTimeValue
3/1/2011 12:00:00 AM
I need to convert it in a String of this format:
Format="yyyy-MM-dd"
Any idea how to do it? PS: I can remove information about the time
Thanks for your time
Use DateTime.ParseExact like so:
DateTime.ParseExact("3/1/2011 12:00:00 AM", "G",
CultureInfo.GetCultureInfo("en-US")).ToString("yyyy-MM-dd");
Be sure to specify the culture, because the format you used is ambiguous.
is this what are you asking for?
DateTime.Parse("3/1/2011 12:00:00 AM").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