Click here to Skip to main content
15,896,477 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
How to return The name of day like "Saturday" From my Computer
I used

DateTime date = new DateTime(DateTime.Now.Date.Day);

MessageBox.Show(date.DayOfWeek.ToString());


but it does not return the correct day and when you change the time in pc it return the same day
please Help
Posted

C#
DayOfWeek dtt = DateTime.Now.DayOfWeek ;
MessageBox.Show(dtt.ToString());


Above code will return just the current day in your computer in string format.
 
Share this answer
 
Look around here: http://www.csharp-examples.net/string-format-datetime/[^]

C#
String.Format("{0:dddd}", DateTime.Now); 
 
Share this answer
 
see the following
using System;

class Program
{
    class Employee
    {
	public DateTime HiringDate { get; set; }
    }

    static void Main()
    {
	//
	// Write the current date and time.
	//
	DateTime now = DateTime.Now;
	Console.WriteLine(now);

	//
	// Store a DateTime in a class.
	//
	Employee employee = new Employee() { HiringDate = now };
	Console.WriteLine(employee.HiringDate);
    }
}
 
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