If the object is of type DateTime, you can simply use the method .ToString()to print in the required format by passing the format string as an argument to .ToString (). Consider the following example:
DateTime currentDate = DateTime.Now;
string format = "dd-MM-yy HH:MM tt";
string formatedDateTime = currentDate.ToString(format, CultureInfo.InvariantCulture);
.