Wrong time displayed in Custom Widget
I can't seem to get the correct time displayed in a Custom Widget.
I created a User Control with a RadGrid and have it registered and working well on the frontend...But one of the columns that displays a datetime is still showing the UTC time in the database and not the timezone that I thought it would be displaying.
I have pacific time set (-8 UTC) under settings and the checkmark checked in "UI Time Zone Config" under Settings->Advanced->System. Changing either of these doesn't seem to change the custom widget datetime though
In the radgrid's ItemDataBound I get the datetime from the column and convert it using ToSiteFinityUITime but it is still in UTC format when the page is displayed.
protected void userHistoryGrid_ItemDataBound(object sender, GridItemEventArgs e)
if (e.Item is GridDataItem)
GridDataItem item = e.Item as GridDataItem;
DateTime utcTime = Convert.ToDateTime(item["lastlogindate"].Text);
DateTime correctTime = Telerik.Sitefinity.SystemExtensions.ToSitefinityUITime(utcTime);
item["lastlogindate"].Text = correctTime.ToString("F");
//item["lastlogindate"].Text = "You at least made it here";
and I do realize I could just -8 the hours for a quick fix...but I didn't know if this was a bug or no.
any help would be great! thanks
Hi Dustin,
You will need to subscribe to the method ItemDataBound
instead of ItemCreated. It may look like this :
void
UsersList_ItemDataBound(
object
sender, GridItemEventArgs e)
if
(e.Item
is
GridDataItem)
GridDataItem item = e.Item
as
GridDataItem;
DateTime localTime = (item.DataItem
as
User).LastLoginDate.ToLocalTime();
item[
"lastLoginDate"
].Text = localTime.ToString();