Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more: (untagged)
How will Show the current date and time in C# and print it in a textbox?
Posted
Updated 7-May-12 22:02pm

C#
DateTime saveNow = DateTime.Now;
Console.WriteLine(saveNow);
 
Share this answer
 
To get the current date and time:
C#
DateTime now = DateTime.Now;

You can then format it to your hearts content - see here: Formatting a DateTime for display - format string description[^]

After that, it's up to you - we have no idea what your environment is, so we can't help you put formatted text anywhere!
 
Share this answer
 
1)You can use DateTime class in C#:

DateTime.Today.ToString("dd/MM/yyyy"); This will give you "08/05/2012"




2) Or you can use JavaScript as :
var dateTime = new Date();
var day = dateTime.getDay();
var month = dateTime.getMonth();
var year = dateTime.getYear();
var displayString = day + "/" + month + "/" + year;


apply this, This will be helpful to you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900