Click here to Skip to main content
15,307,363 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i wanna change window system date time in run time with c#.
pls give me any suggestion.....
Posted
Updated 11-Nov-21 23:13pm
Comments
Simon_Whale 13-Nov-21 13:40pm
   
Just be careful with this as from Windows 7 this needs certain privileges to change the system date time. https://stackoverflow.com/questions/650849/change-system-date-programmatically

   
If it is purely only to display, then you can use the following method:

C#
DateTime currentTime = DateTime.Now;
string format = "dd MM yyyy";
Console.WriteLine(currentTime.ToString());


Here are all the different formats:

1) MM/dd/yyyy 08/22/2006
2) dddd, dd MMMM yyyy Tuesday, 22 August 2006
3) dddd, dd MMMM yyyy HH:mm Tuesday, 22 August 2006 06:30
4) dddd, dd MMMM yyyy hh:mm tt Tuesday, 22 August 2006 06:30 AM
5) dddd, dd MMMM yyyy H:mm Tuesday, 22 August 2006 6:30
6) dddd, dd MMMM yyyy h:mm tt Tuesday, 22 August 2006 6:30 AM
7) dddd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07
8) MM/dd/yyyy HH:mm 08/22/2006 06:30
9) MM/dd/yyyy hh:mm tt 08/22/2006 06:30 AM
10) MM/dd/yyyy H:mm 08/22/2006 6:30
11) MM/dd/yyyy HH:mm:ss 08/22/2006 06:30:07
12) MMMM dd August 22
13) yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK 2006-08-22T06:30:07.7199222-04:00
14) ddd, dd MMM yyyy HH':'mm':'ss 'GMT' Tue, 22 Aug 2006 06:30:07 GMT
15) yyyy'-'MM'-'dd'T'HH':'mm':'ss 2006-08-22T06:30:07
16) HH:mm 06:30
17) hh:mm tt 06:30 AM
18) H:mm 6:30
19) h:mm tt 6:30 AM
20) HH:mm:ss 06:30:07
21) yyyy'-'MM'-'dd HH':'mm':'ss'Z' 2006-08-22 06:30:07Z
22) dddd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07
23) yyyy MMMM 2006 August

I borrowed the list from here List[^]
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900