1

I create a custom field to display the hour and the minute of a date time field.

The format I need is HH:MM

For now, I get the hour in GMT but it is wrong because I am in France and the time zone mooves.

During a half of the year, we are in GMT+1 and for the rest, we are in GMT+2.

Do you knom how I can get the hour in current timezone?

Thanks enter image description here

0

I had to do something similar myself recently. The solution I went with involved two fields, one for checking whether the date within another field was within Daylight Savings Time, and another to translate a date field into a verbose text output e.g. 6:00 PM Friday, December 10, 2016.

It sounds like you could use a similar solution, use a field to determine which side of the +1/+2 the field should be in, then use a formula like IF(Field_is_gmt1__c, date_field__c + 1/24, date_field__c + 2/24)

Checking if a field's date is within DST (these are the US DST dates, not sure if they vary in France):

AND( 
Event__r.EventDate__c >= 
DATE(YEAR(Event__r.EventDate__c),3,8) + MOD(7 - MOD(DATE(YEAR(Event__r.EventDate__c),3,8) - DATE(1900,1,7),7) , 7) 
, 
Event__r.EventDate__c < 
DATE(YEAR(Event__r.EventDate__c),11,1) + MOD(7 - MOD(DATE(YEAR(Event__r.EventDate__c),11,1) - DATE(1900,1,7),7) , 7) 
)
  • the DST is fragile as the 'day of month' changes from year-to-year and not all US jurisdictions use DST – cropredy Mar 20 at 16:42

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.