Can we do something like this in Radzen? If so, how to insert the America/Chicago bit?
<RadzenDataGridColumn TItem="Content" FormatString="{0:MM/dd/yy h:mm:ss 'America/Chicago'}" Property="Created" Title="Created On" Width="100px" />
Any help us much appreciated! Thanks!
Here is how I'm doing it for now.
I created a new property Called CreatedLocal. I added the NotMapped decorator because it's not listed in the database. I added JsonIgnore, so JsonSerializer would ignore the property when serializing my object/class for a Post or Put.
[NotMapped]
[JsonIgnore]
[DisplayFormat(DataFormatString = "{0:MM/dd/yy h:mm:ss}")]
public DateTime? CreatedLocal
{
get
{
if (!String.IsNullOrEmpty(Company.TimeZone))
{
TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById(Company.TimeZone);
TimeSpan offset = tzi.GetUtcOffset(Created);
return Created.Add(offset);
}
else return Created.ToLocalTime();
}
}
As you can see here, I'm now using CreatedLocal instead of Created.
<RadzenDataGridColumn TItem="Content" Property="CreatedLocal" Title="Created On" Width="100px" />