Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- DateTime nowTime = DateTime.Now;
- string strFormat = "{0}:\n{1}\n";
- Console.WriteLine(string.Format(strFormat, "nowTime", nowTime));
- //2014/6/13 15:37:15
- Console.WriteLine(string.Format(strFormat, "nowTime.Date", nowTime.Date));
- //2014/6/13 00:00:00
- Console.WriteLine(string.Format(strFormat, "nowTime.DayOfWeek", nowTime.DayOfWeek));
- //Friday
- Console.WriteLine(string.Format(strFormat, "nowTime.DayOfYear", nowTime.DayOfYear));
- //164
- Console.WriteLine(string.Format(strFormat, "nowTime.Hour", nowTime.Hour));
- //15
- Console.WriteLine(string.Format(strFormat, "nowTime.Year", nowTime.Year));
- //2014
- Console.WriteLine(string.Format(strFormat, "nowTime.Month", nowTime.Month));
- //6
- Console.WriteLine(string.Format(strFormat, "nowTime.Day", nowTime.Day));
- //13
- Console.WriteLine(string.Format(strFormat, "nowTime.Hour", nowTime.Hour));
- //15
- Console.WriteLine(string.Format(strFormat, "nowTime.Minute", nowTime.Minute));
- //37
- Console.WriteLine(string.Format(strFormat, "nowTime.Second", nowTime.Second));
- //15
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement