DateTime dt=new DateTime(05/06/2014) this is in dd/mm/yyyy)
dt.DayOfWeek
raturns value based on mm/dd/yyyy format its taking 5 as month 6 as date. i want this has return a value based on dd/mm/yyyy format.
Please help me guys.
DateTime dt=new DateTime(05/06/2014) this is in dd/mm/yyyy)
dt.DayOfWeek
raturns value based on mm/dd/yyyy format its taking 5 as month 6 as date. i want this has return a value based on dd/mm/yyyy format.
Please help me guys.
Use this:
DateTime(Int32, Int32, Int32)
Initializes
a new instance of the DateTime
structure to the specified year
, month
, and day
.
DateTime dt = new DateTime(2014,6,5);
You can print the date in your specific format:
String.Format("{0:MM/dd/yyyy}", dt); // "05/06/2014"
String.Format("{0:dd/MM/yyyy}", dt); // "06/05/2014"
try using this:
DateTime dt=new DateTime(05/06/2014)
String.Format("{0:dd/MM/yyyy}", dt);
Correct overload for DateTime
is
DateTime(int32 year, int32 month, int32 day)
You are using wrong Contructor, you have to use this Contructor:
DateTime dt = new DateTime(int year, int month, int day);
DateTime(Int32, Int32, Int32) Initializes a new instance of the DateTime structure to the specified year, month, and day.
See its detail here
you can see here on MSDN the list of all Contructors avaiable of DateTime
class.
Predefined datetime structure properties are working based on the Date and time format present in the Regional setting in your system. If you want to use a datetime for your application, you may refer this thread
In datetime function , you also give string format as you required like
DateTime dt = DateTime.ParseExact(yourObject.ToString(), "MM/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
string s = dt.ToString("dd/M/yyyy");
or
string s new datetime().ToString(give format here);
refer link convert datetime to date format dd/mm/yyyy