I have executed following code on developer console and it shows incorrect hour. Since the time used is from Seattle (Pacific time) which is 8 hours behind GMT. So when datetime.hourGMT() is used shouldn't the value be converted to GMT time and then the hour component should be fetched. Please advise if i am missing something or how is the calculation done.
Timezone tz = Timezone.getTimeZone('America/Los_Angeles'); DateTime SeattleTimeTest = DateTime.newInstance(System.Now().getTime() + tz.getOffset(System.Now())); System.debug('Seattle Time ' +SeattleTimeTest+'-->'+SeattleTimeTest.hourGMT());
Seattle Time 2020-01-23 14:41:29-->14