Ahmed Khalid

Ahmed Khalid

  • 2.1k
  • 114
  • 2.6k

DateTime Conversion for Gridview

Feb 3 2023 7:51 PM


I have a GridView that has a timestamp in it and server is in remote location having time other than client timings. I have implemented the time conversion method using template in gridview as shown below. The time is still being displayed as server time. Any idea I can try?

NB: Local time is 2/3/2023 01:34 AM and Server Time is showing as 2/3/2023 8:04:00 AM

Many thanks

<asp:TemplateField HeaderText="Time Stamp" ItemStyle-Width="200">
        <asp:Label ID="lbl_TimeStamp" runat="server" Text='<%# Convert.ToDateTime(Eval("TransTimeStamp", "{0:g}")).ToLocalTime() %>'></asp:Label>


Answers (7)