function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
lapaullapaul 

extract time portion out of a date time object

Hi,

Has anyone have experience in extracting a time portion out of a date time object?

For example: 8/12/2009 2:20 PM

I just want to extract the time 2:20 PM from the date time object above. Please advice.

Your help is expreciated.

 

Paul

 

Best Answer chosen by Admin (Salesforce Developers) 
CRM JediCRM Jedi

Date.Format() will do the job.

 

Example:

 

system.debug(System.NOW().format('hh:mm a'));

 

 

 

Raymond

 

All Answers

CRM JediCRM Jedi

Date.Format() will do the job.

 

Example:

 

system.debug(System.NOW().format('hh:mm a'));

 

 

 

Raymond

 

This was selected as the best answer
lapaullapaul
Thanks so much, it worked.