get current system time

just drag one label from the toolbox then write this code in form_load section



//just drag one label from the toolbox the write this code in form_load section

Label1.Text = DateTime.Now.ToLongTimeString();


Comments

Author: Danasegarane.A10 Oct 2009 Member Level: Gold   Points : 1

Duplicate Post :)

http://www.dotnetspider.com/resources/33721-current-date.aspx

Author: Phagu Mahato11 Oct 2013 Member Level: Gold   Points : 6

DateTime.Now returns the current time and day.There are following example code for date and time in C#
[1] Program that uses DateTime.Now in C#

using System;

class Program
{
class student
{
public DateTime StudyDate { get; set; }
}

static void Main()
{

DateTime now = DateTime.Now;
Console.WriteLine(now);


student student = new student() { studyDate = now };
Console.WriteLine(student.studyDate);
}

[2]Another Program that assigns to DateTime.Now in C#

using System;

class Program
{
static void Main()
{
DateTime now = DateTime.Now;
] Console.WriteLine(now);
System.Threading.Thread.Sleep(10000);

Console.WriteLine(now);
}
}

[3] Program that uses DateTime.Today in C#

using System;

class Program
{
static void Main()
{
DateTime today = DateTime.Today;
DateTime now = DateTime.Now;

Console.WriteLine(today);
Console.WriteLine(now);
}
}



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: