Formatting DateTime Values in the grid to local time in browser?

Mar 26, 2014 at 6:00 PM
I have started using Grid.MVC, and I have the bootstrap 3 formatting working now. Looks great.
However, since my database is storing dates and times in UTC, and I have users in multiple time zones, I am trying to get the dates to be shown in the local time in the browser.

Here is a subset of my grid:

@Html.Grid(Model).Columns(columns =>
{
/* Adding "Location" column: */
columns.Add(o => o.SelectedLocationName)
        .Titled("Location")
        .Sortable(true).SetWidth(215);

/* Adding "HookupApptDate" column: */
columns.Add(o => o.HookUpApptDate, "HookUpApptDate")
        .Titled("Hook Up Appointment")
        .ThenSortBy(o => o.HookUpApptDate)
        .Sortable(true)
        .Format("{0:dd MMM yyyy hh:mm tt}");

/* Adding "FollowupApptDate" column: */
columns.Add(o => o.FollowupApptDate, "FollowApptDate")
        .Titled("Followup Appointment")
        .Sortable(true)
        .Format("{0:dd MMM yyyy hh:mm tt}")
        .SetWidth(155);
}).WithPaging(30)

The FollowupApptDate and HookUpApptDate values in my models are nullable DateTime.
How can I get the values out to put them in the local date time in the browser?
Mar 26, 2014 at 7:04 PM
After some dorking around, I figured it out:

/ Adding "HookupApptDate" column: /
columns.Add(o => o.HookUpApptDate, "HookUpApptDate")
        .Titled("Hook Up Appointment")
        .ThenSortBy(o => o.HookUpApptDate)
        .Sortable(true)
        .RenderValueAs(d => String.Format("{0:dd MMM yyyy h:mm tt}", d.HookUpApptDate.Value.ToLocalTime()));

/* Adding "FollowupApptDate" column: */
columns.Add(o => o.FollowupApptDate, "FollowApptDate")
        .Titled("Followup Appointment")
        .Sortable(true)
        .RenderValueAs(d => String.Format("{0:dd MMM yyyy h:mm tt}", d.FollowupApptDate.Value.ToLocalTime()));____
Marked as answer by Bukharin on 4/5/2014 at 12:17 AM