Wednesday, 11 September 2013

How can I append a leading 0 in MVC 4 DateTime in an EditorFor HTMLHelper?

How can I append a leading 0 in MVC 4 DateTime in an EditorFor HTMLHelper?

I'm running into an issue in my MVC 4 application when using an input mask
in my edit view for a DateTime. The input mask that I'm using forces an
input to be formatted like: "MM/dd/yyyy HH:mm". This works great until an
edit it attempted.
An input of "09/11/2013 07:00" ends up looking like "91/12/0137 30:00" in
my EditorFor helper.
How can I force a "0" to append to a month and hour less than two digits?

No comments:

Post a Comment