0

I need to analyze the "EndDate" of events inside SharePoint 2013 standard calendar items from a list item event receiver and cancel some modifications based on time of this date. I have this code for obtaining the updated date:

string strEnd = (string)properties.AfterProperties["EndDate"];

Unfortunately, the date is coming as string of the such format:

// "2015-04-22T10:30:00Z"

As you can see, there's no any time zone information. When the item is being updated from standard SP web interface, the date string looks like a local time. But if the item is being updated from Outlook, the date string looks like the date which is shifted due to the timezone differences.

The problem is that because of lack of the timezone info I cannot differentiate between this two cases. There's the "TimeZone" column inside calendar list but it returns nothing and I'm not sure is it related to problem.

At the same time, the SharePoint itself somehow knows the right time because in the web interface it shows the right time regardless of the source of the changes.

How should I deal with this situation?

  • Try treating time as UTC – Amal Hashim Apr 22 '15 at 16:28
  • I have to repeat that there's no differences in data - so if I apply the same conversion in both cases the problem would remain – Alex Boev Apr 22 '15 at 16:31
  • what about adding a custom field with the UTC zone? And update the value via JS while creating the item – Nk SP Apr 22 '15 at 18:46
  • First of all, what do you mean "by JS"? Javascript? Javascript cannot help me in any way because here we are talking about event receiver. I need to use the receiver because there would be two ways to edit data - via browser and via Outlook. Let me clarify again - the main problem is not the lack of the timezone by itself. The problem is in the difference between dates inside the receiver depending on the source of the modification. The date "from browser" comes unshifted, the date "from outlook" is shifted. And there's no way to tell which case is it. The same user, different "client app". – Alex Boev Apr 22 '15 at 19:06
  • Did you got solution for the same? – Ravindra Jul 19 '18 at 11:25

Your Answer

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

Browse other questions tagged or ask your own question.