I\'m trying to create a string from the DateTime object which yields the format mm:dd:yyyy
.
Conventionally the DateTime
object comes as
If you want to remove hours, seconds, milliseconds (remove as reset to 0) from a DateTime
object without converting to a string, you can use the Date
property.
// Get date-only portion of date, without its time.
var date = DateTime.Now.Date;
The example below uses the Date property to extract the date component of a DateTime value with its time component set to zero (or 0:00:00, or midnight).
msdn