4
Answers

Urgent - Please help with formating date in Visual C# app

Vinnie

Vinnie

17y
3.3k
1

I have one class for formating date in my web app. The date should be the same for every object in app and should be as a NEWSTRING

   public const string NEWSTRING = "dd/MM/yy HH:mm";

    public static string FormatDate(DateTime date) {
        return date.ToString(NEWSTRING);
    }

When I try to convert for example
    Text1.Text = FormatDate(currentDate); 

where currentDate is:
    DateTime currentDate = "yyyy-mm-dd hh:mm:ss"

I get as the result dd-mm-yy hh:mm instead of dd/MM/yy HH:mm

How can I get the date in format dd/MM/yy HH:mm by using my FormatDate ?

Answers (4)