I have a site where users can make posts. The users can be from all over the globe so when they post, I am storing the posted date as DateTime.UtcNow. I am using the JQuery time ago plug in to show the posted dat similar to stack overflow (1 min ago etc...) But I am not sure how to convert to date I have stored in the system to the users local time? Here is what I am using:
public static MvcHtmlString ConvertToLocalTime(this HtmlHelper htmlHelper, DateTime date)
{
DateTime convertedDate = DateTime.SpecifyKind(DateTime.Parse(date.ToString()),DateTimeKind.Utc);
return MvcHtmlString.Create(convertedDate.ToLocalTime().ToString());
}
This sees to convert the time to the servers local time but I need it for the users local time. What am I doing wrong? I am using .NET MVC 2 and .NET 4.0