We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

render a DateTime column in local time, not in UTC

Thread ID:





30712 Jun 22,2005 03:48 PM UTC Jun 22,2005 05:27 PM UTC WinForms 1
Tags: GridControl
Asked On June 22, 2005 03:48 PM UTC

Hi, I want to display a column with DateTime objects in it. But if I try to set the format string either to col.StyleInfo.Format = CultureInfo.CurrentCulture.DateTimeFormat.FullDateTimePattern ; or to col.StyleInfo.Format = "dd.MM.yy - HH:mm:ss"; all the times are displayed as UTC. How can I tell the StyleInfo to use the local timezone? Otherwise it would be a great deal to convert all the table entries manual. Thanks in advance, Alex.

Administrator [Syncfusion]
Replied On June 22, 2005 05:27 PM UTC

So, the dates are displayed in the proper format, it is just that the time is the wrong value. If this is a readonly grid, then you could use the grid.DrawCelDisplayText event. There you can get the DateTime object from the style.CellValue. Then call the ToLocalTime() method on this DateTime object to convert it from UTC to local. Then you can format the converted object, and set the formatted string into e.Text. If it is not a ReadOnly grud, then you would have to use the QueryCellFormattedText and SaveCellFormattedText events to flip the time from UTC to local in QueryCellFromattedText and then from local to UTC in SaveCellFormattedText. DateTime d; d.ToLocalTime();


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon