locked
How to Get Current Site Time? RRS feed

  • Question

  • Hi,

    I've created a web part in my DispForm.aspx. This web part will log the current site Time on a DataBase.

    I've used SPTimeZone.UTCToLocalTime(DateTime.Now) to log the time.

    But when I update an item in a list, then after updating i've viewed its properties. It has a very large difference between Modified and SPTimeZone.UTCToLocalTime(DateTime.Now).

    Can anyone please help me get the site time

    Thanks

    Wednesday, July 25, 2012 6:33 AM

Answers

  • You should pass the (DateTime.UtcNow) rather than (DateTime.Now).

    SPTimeZone.UTCToLocalTime is expected to have the UTC time rather than local time. 

    Wednesday, July 25, 2012 7:35 AM