My windows date format is month / date / year. If I want to set StartTime with the format "yyyy / MM / dd HH: mm: ss", how can I do this. I am trying the following code.
DateTime StartTime = DateTime.ParseExact("2011/01/04 09:30:00", "yyyy/MM/dd HH:mm:ss", null);
But StartTime comes out from 1/4/2011 9:30:00. (month / date / year hh: mm: ss)
Your format is used to handle the date correctly, but it is displayed by default. To display it in the format in which you created it, you will need to either use String.Format , or even use "ToString ()" using the template .
, . StartTime.ToString("yyyy/MM/dd HH:mm:ss")
StartTime.ToString("yyyy/MM/dd HH:mm:ss")
This code works correctly, and now you have a DateTime object with a strong type.
If you want to output it in the above format, you call ToString () with the format in the second argument.
MSDN is your friend: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
You can also set a breakpoint to check the StartTime value to find out what is actually in it.
Source: https://habr.com/ru/post/1783422/More articles:Reset.css is a colgroup overriding background in IE7 / IE6 - htmlFroYo cupcake for market problems (application not shown to some people or listed on appbrain) - androidHow to get GPS coordinates every minute in Android? - javaJava: detecting a dead end in implicit queues when debugging a breakpoint - javaФункция обратного вызова с параметрами - javascriptStatement.cancel () and its security guarantee (s) - javaHow is the echo symbol 0x96 in a batch file? - commandwindows phone 7-page transition to yourself - windows-phone-7Delete temporary file during final removal of output file during catch - javaРазличия в синтаксисе SQL между SQL Server 2005 и ADO.Net? - .netAll Articles