With the following code you can format a DateTime within a Databind.
<%# DateTime.Parse(Eval("DateModified").ToString()).ToString("MM-dd-yyyy")%>
Some more format specifiers that can change format of datetime objects the way it is required.
Format specifier | Name |
---|---|
d | Short date pattern |
D | Long date pattern |
t | Short time pattern |
T | Long time pattern |
f | Full date/time pattern ( short time ) |
F | Full date/time pattern ( long time ) |
g | General date/time pattern ( short time ) |
G | General date/time pattern ( long time ) |
M or m | Month day pattern |
R or r | RFC1123 pattern |
s | Sortable date/time pattern; conforms to ISO 8601 |
u | Universal sortable date/time pattern |
U | Universal sortable date/time pattern |
Y or y | Year month pattern |