c# - Set date time format in asp -


one question problem, changes made seems no effect.

in main file have below code:

<tr id="trorderdate" runat="server">   <td class="padloff" style="text-align: left"><b>order date:</b></td>   <td><asp:textbox id="lblorderdate" runat="server" cssclass="form-control" readonly="true" /></td> </tr> 

behind lblorderdate id, have code below:

lblorderdate.text = order.summary.orderdate.tostring("dd/mm/yyyy"); 

the result show below: enter image description here

i have tried removed format below code show full data (date , time):

lblorderdate.text = order.summary.orderdate.tostring(); 

but result still show previous image. have checked data in database have include date time format.

have idea on issue or way me show date , time.

thanks

simply:

lblorderdate.text = order.summary.orderdate.tostring("dd/mm/yyyy hh:mm:ss"); 

or

lblorderdate.text = string.format("{0:dd/mm/yyyy hh:mm:ss}", order.summary.orderdate); 

or @fhogberg

lblorderdate.text = order.summary.orderdate.tolongdatestring(); 

Comments