cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
leslie_rivera
Resolver I
Resolver I

TimeZoneOffset Function

Trying to figure out how to use TimeZoneOffset. I have read all the documents relaying to TimeZoneOffset but cant find any real life examples. I am trying to reflect Mountain Standard Time. See below formula.

 

Set(StartDateTimeUTC, Text(DateAdd(StartDateTime, -TimeZoneOffset(StartDateTime), Minutes), "[$-en-US]yyyy-mm-ddThh:mm") & ":00.000Z");
Set(EndDateTimeUTC, Text(DateAdd(EndDateTime, -TimeZoneOffset(StartDateTime), Minutes), "[$-en-US]yyyy-mm-ddThh:mm") & ":00.000Z");

3 ACCEPTED SOLUTIONS

Accepted Solutions
leslie_rivera
Resolver I
Resolver I

Solution on the OnVisible of the Confirmation Screen:
If(
IsBooking,
UpdateContext({ShowLoading: true});
If(
!BookForMeeting,
Office365.V4CalendarPostItem(
MyCalendar,
User().FullName & "'s Booking",
StartDateTime,
EndDateTime,
"Mountain Standard Time",
{
requiredAttendees: RoomsGallery.Selected.Email,
location: RoomsGallery.Selected.Name,
importance: "normal",
showAs: "busy"
}
),
ClearCollect(
RequiredAttendeesNoRoom,
Split(
MeetingsGallery.Selected.RequiredAttendees,
";"
)
);
ForAll(
AllRooms,
RemoveIf(
RequiredAttendeesNoRoom,
Address = Result
)
);
ClearCollect(
RequiredAttendeesNoRoom,
Concat(
RequiredAttendeesNoRoom,
Result & ";"
)
);
ClearCollect(
RequiredAttendeesNoRoom,
Split(
First(RequiredAttendeesNoRoom).Value,
";;"
)
);
Set(
RequiredAttendeesFinal,
First(RequiredAttendeesNoRoom).Result
);
Set(
RequiredAttendeesTrue,
RoomsGallery.Selected.Email & ";" & RequiredAttendeesFinal
);
Set(
OriginalBody,
Office365.V3CalendarGetItem(
MyCalendar,
MeetingsGallery.Selected.Id
).body
);
Office365.V4CalendarPatchItem(
MyCalendar,
MeetingsGallery.Selected.Id,
If(
MeetingsGallery.Selected.Subject = User().FullName & "'s Zoom Meeting",
User().FullName & "'s Booking",
MeetingsGallery.Selected.Subject
),
StartDateTime,
EndDateTime,
"Mountain Standard Time",
{
requiredAttendees: RequiredAttendeesTrue,
optionalAttendees: MeetingsGallery.Selected.OptionalAttendees,
body: OriginalBody,
location: RoomsGallery.Selected.Name,
importance: "Normal",
showAs: "Busy",
isHtml: true
}
)
);
UpdateContext({ShowLoading: false})
);
Set(
IsBooking,
false
)

View solution in original post

leslie_rivera
Resolver I
Resolver I

On the ConfirmationScreen.. The OnVisible.. see formula below:

 

If(
IsBooking,
UpdateContext({ShowLoading: true});
If(
!BookForMeeting,
Office365.V4CalendarPostItem(
MyCalendar,
User().FullName & "'s Booking",
StartDateTime,
EndDateTime,
"Mountain Standard Time",
{
requiredAttendees: RoomsGallery.Selected.Email,
location: RoomsGallery.Selected.Name,
importance: "normal",
showAs: "busy"
}
),
ClearCollect(
RequiredAttendeesNoRoom,
Split(
MeetingsGallery.Selected.RequiredAttendees,
";"
)
);
ForAll(
AllRooms,
RemoveIf(
RequiredAttendeesNoRoom,
Address = Result
)
);
ClearCollect(
RequiredAttendeesNoRoom,
Concat(
RequiredAttendeesNoRoom,
Result & ";"
)
);
ClearCollect(
RequiredAttendeesNoRoom,
Split(
First(RequiredAttendeesNoRoom).Value,
";;"
)
);
Set(
RequiredAttendeesFinal,
First(RequiredAttendeesNoRoom).Result
);
Set(
RequiredAttendeesTrue,
RoomsGallery.Selected.Email & ";" & RequiredAttendeesFinal
);
Set(
OriginalBody,
Office365.V3CalendarGetItem(
MyCalendar,
MeetingsGallery.Selected.Id
).body
);
Office365.V4CalendarPatchItem(
MyCalendar,
MeetingsGallery.Selected.Id,
If(
MeetingsGallery.Selected.Subject = User().FullName & "'s Zoom Meeting",
User().FullName & "'s Booking",
MeetingsGallery.Selected.Subject
),
StartDateTime,
EndDateTime,
"Mountain Standard Time",
{
requiredAttendees: RequiredAttendeesTrue,
optionalAttendees: MeetingsGallery.Selected.OptionalAttendees,
body: OriginalBody,
location: RoomsGallery.Selected.Name,
importance: "Normal",
showAs: "Busy",
isHtml: true
}
)
);
UpdateContext({ShowLoading: false})
);
Set(
IsBooking,
false
)

View solution in original post

leslie_rivera
Resolver I
Resolver I

Solution.. changed to V4 and coded Mountain Time. See below attachment for code.

View solution in original post

23 REPLIES 23
RandyHayes
Super User III
Super User III

@leslie_rivera 

Actually, you can get to the UTC much quicker with your Text function.

Please consider changing your Formula to the following:

Set(StartDateTimeUTC, Text(StartDateTime, UTC));
Set(EndDateTimeUTC, Text(EndDateTime, UTC));

Usually all of the date functions in PowerApps will reflect their values based on the regional information about the browser/player.  So, if you are in Mountain Time, it will reflect Mountain Time.

 

Are you running into a specific issue?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
leslie_rivera
Resolver I
Resolver I

Yes I am using the Book a Room template and in the app it reflects the time correctly, and when its booked in the users calendar the time is correct. My issue is with the email auto response that shows UTC time confusing my users.

 

leslie_rivera_0-1621364245914.png

 

RandyHayes
Super User III
Super User III

@leslie_rivera 

I am not familiar with that template, but in general, it sounds like the TimeZone information when the event is created, is not being passed properly.

I assume this is creating an event that then appears on the calendars.  So there is somewhere a V3CalendarPostItem action.  That action should have the time zone information in it.  It is an optional parameter, but this should resolve that aspect.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
leslie_rivera
Resolver I
Resolver I

@RandyHayes  I think this is the parameter  you are talking about:

 

If(IsBooking,
UpdateContext({ShowLoading: true});
If(!BookForMeeting,
Office365.V2CalendarPostItem(MyCalendar, User().FullName & "'s Booking", StartDateTime, EndDateTime,
{RequiredAttendees:RoomsGallery.Selected.Email, Location: RoomsGallery.Selected.Name, Importance: "Normal", ShowAs: "Busy"}),

ClearCollect(RequiredAttendeesNoRoom, Split(MeetingsGallery.Selected.RequiredAttendees, ";"));
ForAll(AllRooms, RemoveIf(RequiredAttendeesNoRoom, Address = Result));
ClearCollect(RequiredAttendeesNoRoom, Concat(RequiredAttendeesNoRoom, Result & ";"));
ClearCollect(RequiredAttendeesNoRoom, Split(First(RequiredAttendeesNoRoom).Value, ";;"));
Set(RequiredAttendeesFinal, First(RequiredAttendeesNoRoom).Result);
Set(RequiredAttendeesTrue, RoomsGallery.Selected.Email & ";" & RequiredAttendeesFinal);
Set(OriginalBody,Office365.V3CalendarGetItem(MyCalendar, MeetingsGallery.Selected.Id).body);
Office365.V2CalendarPatchItem(MyCalendar, MeetingsGallery.Selected.Id, If(MeetingsGallery.Selected.Subject = User().FullName & "'s Zoom Meeting", User().FullName & "'s Booking", MeetingsGallery.Selected.Subject), StartDateTime, EndDateTime, {RequiredAttendees: RequiredAttendeesTrue, OptionalAttendees: MeetingsGallery.Selected.OptionalAttendees,Body:OriginalBody,Location: RoomsGallery.Selected.Name, Importance: "Normal", ShowAs: "Busy",IsHtml:true})
);

UpdateContext({ShowLoading: false})
);
Set(IsBooking, false)

leslie_rivera
Resolver I
Resolver I

@RandyHayesI tried putting in timezone Mountain Standard Time but it booked my 1030am meeting 430pm

leslie_rivera_2-1621369126170.pngleslie_rivera_3-1621369135217.png

 

RandyHayes
Super User III
Super User III

@leslie_rivera 

Unfortunately your image of the formula is too small for me to see it.  It does appear, when I zoom the image as large as I can, that you have included the TimeZone parameter, that is good.  You DO need to supply your start and end times as UTC though.  I cannot tell in the image if you are doing that or not.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes
leslie_rivera
Resolver I
Resolver I

@RandyHayesHere is a better image

 

leslie_rivera_0-1621439733941.png

 

IF you cant see image copied here:

If(IsBooking,
UpdateContext({ShowLoading: true});
If(!BookForMeeting,
Office365.V2CalendarPostItem(MyCalendar, User().FullName & "'s Booking", StartDateTimeUTC, EndDateTimeUTC,
{TimeZone:"Mountain Standard Time",RequiredAttendees:RoomsGallery.Selected.Email, Location: RoomsGallery.Selected.Name, Importance: "Normal", ShowAs: "Busy"}),

ClearCollect(RequiredAttendeesNoRoom, Split(MeetingsGallery.Selected.RequiredAttendees, ";"));
ForAll(AllRooms, RemoveIf(RequiredAttendeesNoRoom, Address = Result));
ClearCollect(RequiredAttendeesNoRoom, Concat(RequiredAttendeesNoRoom, Result & ";"));
ClearCollect(RequiredAttendeesNoRoom, Split(First(RequiredAttendeesNoRoom).Value, ";;"));
Set(RequiredAttendeesFinal, First(RequiredAttendeesNoRoom).Result);
Set(RequiredAttendeesTrue, RoomsGallery.Selected.Email & ";" & RequiredAttendeesFinal);
Set(OriginalBody,Office365.V3CalendarGetItem(MyCalendar, MeetingsGallery.Selected.Id).body);
Office365.V2CalendarPatchItem(MyCalendar, MeetingsGallery.Selected.Id, If(MeetingsGallery.Selected.Subject = User().FullName & "'s Zoom Meeting", User().FullName & "'s Booking", MeetingsGallery.Selected.Subject), StartDateTimeUTC, EndDateTimeUTC, {RequiredAttendees: RequiredAttendeesTrue, OptionalAttendees: MeetingsGallery.Selected.OptionalAttendees,Body:OriginalBody,Location: RoomsGallery.Selected.Name, Importance: "Normal", ShowAs: "Busy",IsHtml:true})
);

UpdateContext({ShowLoading: false})
);
Set(IsBooking, false)

 

In the app it shows the correct time but now its booking my 10am meeting at 4pm

RandyHayes
Super User III
Super User III

@leslie_rivera 

So I see that you are using V2 of the CalendarPostItem action.  I am sure, since you are just using the template, that you did not purposely put that in.  It is a deprecated action. V4 is current.  

However, there has long been a series of flip flopping on the start/enddate arguments for that action.  IN your case, I believe you will actually need to supply the start and end dates NOT in UTC as I last mentioned.

They should be the true start and end times based on the time zone that they should occur.  The TimeZone will establish a conversion base for any other zone that sees the notice.

Also, the two parameters should be supplied as text and not a datetime. And, they should be in the yyyy-mm-ddTHH:mm:ssZ format.

 

So, in the formula you would, for example, replace the StartDate with 

Text(StartTime, "yyyy-mm-ddTHH:mm:ssZ")

 Where StartTime is the actual start time (not time zone adjusted).

 

These post actions are confusing because they keep changing formats and timezone requirements on them version after version.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,923)