+1 vote
52 views
by (163k points)

From UI I am getting this input:

Date : 2020-09-25 Time : 12:15 AM

Now when I try to save this to DB it saves as 2020-09-24T17:15:00.000Z

And when it gets shown in UI again after refresh the time changes to 12:15 PM

The logic is summarized below, try to run this, the final result changes to PM:

String strFormattedCorpTime = '12:15 AM'.split(' ')[0] + ':00' + '12:15 AM'.split(' ')[1];

System.debug(strFormattedCorpTime);
System.debug(Datetime.valueOf('2020-09-25'+' '+strFormattedCorpTime).format('yyyy/dd/MM hh:mm a'));

I would like to save 12:15 AM in GMT format, so that while showing on UI it shows whatever user has saved datetime with. How can I do that?

1 Answer

Welcome to Memory Exceeded, where you can ask questions and receive answers from other members of the community.
...