Vaibhav Patil
Vaibhav Patil

Reputation: 37

How can i change date format in entity framework(C#) yyyy/mm/dd to dd/mm/yyyy

public class Coupon{   public datetime startdate{get;set;}   }

Below model have yyyy/dd/mm:hh:mm:ss format in entity framework by default but i want chage to dd/mm/yyyy So please help me

there is any attribute for date format

Upvotes: 0

Views: 2343

Answers (1)

bartselen
bartselen

Reputation: 26

When converting the DateTime instance to a string, format it like so (assuming a DateTime instance called dtObject): dtObject.ToString("dd/MM/yyyy");. Note that the formatting is case sensitive, so "MM" should be upper case while "dd" and "yyyy" should be lower case.

Upvotes: 1

Related Questions