+ Start a Discussion
AkkiAkki 

Daylight Savings when updating using Apex

'm trying to send out webcast emails to contacts when they register for a webcast on the website. The trigger looks for the country in the leads field and set's the time zone accordingly. Here's how I'm doing it

String WCTime = c.Webcast_Time__c.format('h:mm a zzzz',l.timezone__c);

where l.timezone__c can be something like this -"Asia/Calcutta" . The code get's the time correctly but doesn't take the Daylight Savings into account as I'm sending this email from UK. Is there a way to update the time taking the daylight savings into account? 

Nick34536345Nick34536345

Can you give an example of the time input and output?

 

I tested this:

 

Datetime.now().format('h:mm a zzzz', 'Asia/Calcutta')

 

which gives the correct time in India. Bearing in mind that UK is in DST now, and India doesn't use DST.

 

 

AkkiAkki

We were just discussing about this problem in the office and we realised that the problem was because we were using november date when DST was off. So it's all working fine now.

 

Thanks for the help anyways.