Home » Asp.netRSS

add column to gridview to convert date

can I add a column to gridview that will convert the utc date to my local time?  HOw? 

 

2 Answers Found

 

Answer 1

This converts the utc  time to pacific time  but not central time...which is my time....???

<asp:TemplateField HeaderText="My time">
                    <ItemTemplate>
                       <%#Eval("time").ToLocalTime()%>
                    </ItemTemplate>
                </asp:TemplateField>


 

 

Answer 2

you can apply TimeZoneInfo to convert  from utc  to your local  time 'CST'

the documentation has an example: http://msdn.microsoft.com/en-us/library/system.timezoneinfo.converttimefromutc.aspx

 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter