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
MriduMridu 

Date format for the following date:Nov 25th,2010

I need to display the date in "Nov 25th,2010" format.How can i include "th" along with date format.

Best Answer chosen by Admin (Salesforce Developers) 
ngabraningabrani

You could call static methods day, year and month on Date class to get 25,2010 and Nov. To get the suffix "th", you could call an Apex method that will perform processing something like -

if((day ==1) or (day == 21) or (day ==31)) return 'st';

elseif ((day ==2) or (day == 22)) return 'nd';

elseif ((day ==3) or (day == 23)) return 'rd';

else return 'th';

 

All Answers

ngabraningabrani

You could call static methods day, year and month on Date class to get 25,2010 and Nov. To get the suffix "th", you could call an Apex method that will perform processing something like -

if((day ==1) or (day == 21) or (day ==31)) return 'st';

elseif ((day ==2) or (day == 22)) return 'nd';

elseif ((day ==3) or (day == 23)) return 'rd';

else return 'th';

 

This was selected as the best answer
MriduMridu

Thanks for your help.Its working nw