An example of time formatting in asp. net pages

  • 2020-12-10 00:41:09
  • OfStack

The asp. net page displays the time in Eval as "yyyy-ES5en-ES6en" format


<table>
  <tr>
    <td style="width:273px;color:#105db5;" valign="top"> 【 ** Platform 】 &nbsp;&nbsp;<a href="javascript:void(0)" style="color:#6c6c72" title='<%#                        Eval("fileNameAll")%>' onclick='openPreview(<%# Eval("fileId")%>)'><%# Eval("fileName")%></a></td>
   <td style="padding-right:0px;color:#888;" valign="top"><%# Convert.ToDateTime(Eval("fileCreateDate")).ToString("yyyy-MM-dd")%></td>
  </tr>
</table>

Since the Eval binding returns an Object type, it cannot be converted directly to the date format,

Modified into such as


<%# Convert.ToDateTime(Eval("fileCreateDate")).ToString("yyyy-MM-dd")%>

The display time is "ES18en-ES19en-ES20en";


Related articles: