You need to sign in to do that
Don't have an account?

Create an event in another timezone
I have a visualforce page that shows available resources for a specific day. The resource scheduler will pick a date/time that a new appointment will be scheduled for (using inputField of an Event object instance startdatetime field). They will then pick the resource that they want to schedule the event for.
In this example the resource scheduler is in America/Los_Angeles timezone, the resource is in America/New_York timezone. If the resource scheduler picks 8am on the calendar, I want it to create an event at 8am in the resources timezone (America/New_York). By default just using the datetime field it creates it in the resource schedulers timezone (as expected), and then of course the resource is seeing it as 11 am (which is not what I want). I don't see a way to force a timezone on a datetime field.
How can I get it to create it at 8am for America/New_York timezone if my running user is on Americ/Los_Angeles?
I've even tried updating the running users timezone to the selected resources timezone, created the event, then set the running users timezone back...but that doesn't see to work. It always creates it in whatever time zone they initally were.
In this example the resource scheduler is in America/Los_Angeles timezone, the resource is in America/New_York timezone. If the resource scheduler picks 8am on the calendar, I want it to create an event at 8am in the resources timezone (America/New_York). By default just using the datetime field it creates it in the resource schedulers timezone (as expected), and then of course the resource is seeing it as 11 am (which is not what I want). I don't see a way to force a timezone on a datetime field.
How can I get it to create it at 8am for America/New_York timezone if my running user is on Americ/Los_Angeles?
I've even tried updating the running users timezone to the selected resources timezone, created the event, then set the running users timezone back...but that doesn't see to work. It always creates it in whatever time zone they initally were.
) why can't the resource scheduler convert the date time to their timezone ( ie they have to enter 5 AM which will show 8 AM to the Resouce instead of entering 8 AM which is showing 11 AM to the Resource).
2) If you dont want the resource scheduler to convert, then basically while saving the appointment you have to do the conversion using
1) Get the Resource scheduler timezone offset (UserInfo.getTimeZone().getOffset(DateTIme))
2) Get the Resouce timezone offset (Get user timezone string and use TimeZone.getTimeZone( 'America/Los_Angeles');)
3) Find the difference between timezone offsets and add that difference to scheduled DateTime
All Answers
) why can't the resource scheduler convert the date time to their timezone ( ie they have to enter 5 AM which will show 8 AM to the Resouce instead of entering 8 AM which is showing 11 AM to the Resource).
2) If you dont want the resource scheduler to convert, then basically while saving the appointment you have to do the conversion using
1) Get the Resource scheduler timezone offset (UserInfo.getTimeZone().getOffset(DateTIme))
2) Get the Resouce timezone offset (Get user timezone string and use TimeZone.getTimeZone( 'America/Los_Angeles');)
3) Find the difference between timezone offsets and add that difference to scheduled DateTime
DateTime myDate = dummyE.StartDateTime;
TimeZone utz = UserInfo.getTimeZone();
Integer offset = utz.getOffset(myDate)/ (60 * 60 * 1000);
TimeZone tz1 = TimeZone.getTimeZone(tz);
Integer offset1 = tz1.getOffset(myDate) / (60 * 60 * 1000);
Integer t = offset - offset1;
myDate = myDate.addHours(t);