Reputation: 2433
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Date") %>'></asp:Label>
Displays
03.06.2014 10:30:00
How can I display it as 3 Jun 2014 10:30
Upvotes: 7
Views: 34725
Reputation: 31249
Maybe something like this:
Bind("Date").ToString("d MMM yyyy hh:mm")
You could also do this:
string.Format("{0:d MMM yyyy hh:mm}",Bind("Date"))
Upvotes: 1
Reputation: 10191
Try this:
Text='<%# Eval("Date", "{d MMM yyyy hh:mm}") %>'
You can see more format strings here.
Upvotes: 3
Reputation: 2592
this would display
<asp:Label ID="Label1" runat="server" Text='<%# ((DateTime)Bind("Date")).ToString("f", System.Globalization.CultureInfo.CreateSpecificCulture("en-US")) %>'></asp:Label>
Upvotes: 0
Reputation: 460208
This should work:
<asp:Label ID="Label1" runat="server"
Text='<%# Eval("Date", "{0:d MMM yyyy HH:mm}") %>'>
</asp:Label>
See: Custom Date and Time Format Strings
Upvotes: 21
Reputation: 4354
Try this
<asp:Label ID="Label1" runat="server"
Text='<%# Bind("Date").ToString("d MMM yyyy hh:mm:ss",CultureInfo.CreateSpecificCulture("en-US")) %>'>
</asp:Label>
Upvotes: 1