New answers tagged

1

I may assume, that you need DateTime, not Date, because you have hours and minutes specified. Datetime.valueOf() works for format yyyy-MM-dd HH:mm:ss, so you need to replace T with space and remove Z. String toConvert = '2021-06-15T02:30:00.000Z'; toConvert = toConvert.replace('T', ' ').replace('Z', ''); Datetime actualDatetime = Datetime.valueOf(...


1

Here you can convert this using Date static class. System.debug(Date.valueOf('2021-06-15T02:30:00.000Z'));


0

I found the solution for summertime (DATETIMEVALUE(TEXT(YEAR({!$Record.datefield__c}))&"-"&TEXT(MONTH({!$Record.datefield__c__c})) &"-" &TEXT(DAY({!$Record.datefield__c}))&" "&{!$Record.timefield__c}))-0.0833


3

.hour() and .date() functions show time in user local time zone already, so you do not need to add offset to now variable. now = Datetime.now(); hourNow = now.hour(); todayDate = now.date();


3

All time zones in Salesforce are GMT in the backend. You will need to utilize the TimeZone class to correct for this. After all, your visitor might be coming from anywhere in the world, even if it is EST. To fix this, select the appropriate TimeZone from the class: TimeZone easternTimeZone = TimeZone.getTimeZone('America/New_York'); Then subtract that time ...


Top 50 recent answers are included