I want to change format of datetime command format in c#
Lbldate.content = DateTime.Now.Tostring();
The result is 11/3/2022 But i want it to show me 2022/11/03
When you call ToString
without parameters, the system default format will be used, whatever that might be. It will be different on different systems, depending on culture and user settings. If you want a specific format then you need to pass the appropriate format specifier when calling ToString
. It appears that you want this:
Lbldate.content = DateTime.Now.Tostring("yyyy/MM/dd");
You should read up about standard and custom format strings for dates, times and numbers.