2

I try to create event with php-sdk but setting start and end timezone not working.

$e = new Model\Event();
  $e->setSubject($subject);

$start = new Model\DateTimeTimeZone();
  $start->setDateTime($startDateTime);
  $start->setTimeZone($startTimeZone);

$e->setStart($start);
$e->setEnd($start);

$body = new Model\ItemBody();
  $body->setContentType(Model\BodyType::HTML);
  $body->setContent($content);

$e->setBody($body);

But the result event is every time in UTC.

I tried:

$e->setOriginalStartTimeZone($startTimeZone);
$e->setOriginalEndTimeZone($startTimeZone);

and adding a header:

Prefer: outlook.timezone="Pacific Standard Time"

But the result is same.

On top of that when I add

$e->setReminderMinutesBeforeStart(8);
$e->setIsReminderOn(true);

The remainder is disabled. If I don't include this code the reminder is enabled 15 minutes before the event.

Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63

1 Answers1

2

You're setting both the dateTime and the timeZone to UTC. I'm not sure what you are expecting to happen, but this should generate a new event using UTC.

When you specify time using the Z suffix you are, by definition, telling it "this is Coordinated Universal Time". It is the equivalent of setting the date/time offset to UTC -0:

The time zone using UTC is sometimes denoted UTC±00:00 or by the letter Z—a reference to the equivalent nautical time zone (GMT), which has been denoted by a Z since about 1950.

If you want to use "Pacific Standard Time" then you would want to use

$start = new Model\DateTimeTimeZone();
  $start->setDateTime("2019-03-11T21:01:57");
  $start->setTimeZone("Pacific Standard Time");

Although you might be able to simply use -08:00 as the UTC offset (I'm not experienced enough with the PHP SDK to know if this would work off the top of my head, but I imagine it would):

$start = new Model\DateTimeTimeZone();
  $start->setDateTime("2019-03-11T21:01:57-08:00");
Marc LaFleur
  • 31,987
  • 4
  • 37
  • 63