In DATA TIME field,how to exact time field and how to display it in AM OR PM format.

for example this is:

                  startdate--> 2018-06-03 19:00:00
                  Enddate-->  2018-06-03 19:30:00

I have to extract time field in Apex controller.I have to display it as 7PM - 7.30PM


It seems you want to get the time in 12 hour format.

You can use datetime format method for this. For example,

startdate.format('HH:mm a')

See if this helps!

  • Is it possible to display the month of the date like "march27" – SFDC FAN Jun 9 '18 at 10:49

Your Answer

