+ 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.