/ Published in: C#
Basic examples on the usage of the DateTime objects.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// outputting today's date formatted as dd/mm/yyyy Console.WriteLine(DateTime.Now.ToString("dd/MM/yyyy")); // creating a DateTime object Console.WriteLine(miyazakiBirthDate.ToString("dd/MM/yyyy")); // example of DateTime arithmethic operation DateTime miyazakiBirthNextDay = miyazakiBirthDate + oneDay; Console.WriteLine(miyazakiBirthNextDay.ToString("dd/MM/yyyy")); // another way to output a formatted DateTime Console.WriteLine(string.Format("{0:MM/dd/yyy}", miyazakiBirthDate));