Difference between revisions of "6236 Programmering I Agenda/Date time"
From Teknologisk videncenter
Line 11: | Line 11: | ||
</source> | </source> | ||
+ | <pre style="background:rgba(0,0,0,1); color:#FFFFFF"> | ||
+ | |||
+ | 31.12.2015 22:25:05 | ||
+ | |||
+ | </pre> | ||
==Opgave== | ==Opgave== | ||
+ | Ret i programmet så output formatet bliver | ||
+ | <pre style="background:rgba(0,0,0,1); color:#FFFFFF"> | ||
+ | |||
+ | 31. Dec 2015 kl 10:25:05 PM | ||
+ | |||
+ | </pre> |
Revision as of 10:58, 20 November 2015
Hvis der skal gemmes en dato i C# kan det gøres i datatypen DateTime.
//Opret en DateTime med datoen 31/12-2015 Kl 22:25:05
DateTime d = new DateTime(2015, 12, 31, 22, 25, 05);
//Udskriv DateTime i formatet
System.Console.WriteLine(d.ToString("dd.MM.yyyy HH:mm:ss"));
31.12.2015 22:25:05
Opgave
Ret i programmet så output formatet bliver
31. Dec 2015 kl 10:25:05 PM