Showing posts with label 1. Program to Display current Date and time. Show all posts
Showing posts with label 1. Program to Display current Date and time. Show all posts

Sunday, December 12, 2010

Program to Display current Date and time

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DateandTime
{
public class Time
{
public void DisplayCurrentTime()

{
Console.WriteLine("{0}/{1}/{2} {3}:{4}:{5}", Month, Date, Year, Hour, Minute, Second);

}
//declaring constructor
public Time(System.DateTime dt)
{
Year = dt.Year;
Month = dt.Month;
Date = dt.Day;
Hour = dt.Hour;
Minute = dt.Minute;
Second = dt.Second;
}
int Year, Month, Date, Hour, Minute, Second;
}
public class tester
{
static void Main()
{
System.DateTime currentTime = System.DateTime.Now;
Time t = new Time(currentTime);
t.DisplayCurrentTime();
}
}
}