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 

How to convert a date string format

Hi,

I'm trying to convert the Datetime function to a string format in Apex code using the following command but it displays incorrect date like this: 51/30/2010. Any ideas? Please help.

 

Datetime.now().format(

 

Thanks,

Paul

 

'mm/dd/yyyy')

Imran MohammedImran Mohammed

Try Datetime.now().format('MM/dd/yyyy')

Mark this as accepted solution if you find the this as solution.

lapaullapaul

Thank you so much. It works.