How to format Date like this: Sun, 28 Mar, 2021

I need to format a date with the next format and I don’t know how to:

Sun, 28 Mar, 2021

in case of a variable of datatype DateTime is present or now can be used with toString we can format:
YourDateTimeVar.toString(“ddd, dd MMM, yyyy”)

in case of a date string is to reformat

  • we do parse the date string into a DateTime
  • then we use toString as shown above
1 Like

Check this below code,
DateTime.ParseExact(“Sun, 28 Mar, 2021”,“ddd, dd MMM, yyyy”, System.Globalization.CultureInfo.InstalledUICulture).ToString(“dd-MM-yyyy”)

Output : 28-03-2021

Hope this may help you :slight_smile:

1 Like

Thank u, u know any good tutorial to know how to format strings?

official references is a good information resource:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.