1

I have a question, basically i have a date time which is by default in UTC, how do i programmatically convert it to a correct date time in regional settings of the site collection / or user?

5

For full explanation see Dealing with Multiple Time Zones in SharePoint 2010

var user = SPContext.Current.Web.CurrentUser;
// Always perform a Null-Check on SPUser.RegionalSettings
if (user.RegionalSettings != null)
{
    return user.RegionalSettings.TimeZone.UTCToLocalTime(listDateUtc);
}
else
{
    // User didn't set a time zone, so use the one from the Web
    return SPContext.Current.Web.RegionalSettings.TimeZone.UTCToLocalTime(listDateUtc);
}
1
  • 1
    Any way you could convert this to JSOM? I tried but can't seem to figure it out. – IMTheNachoMan Dec 7 '15 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.