+ Start a Discussion
VSK98VSK98 

How to get the Date (YYYY-MM-dd) format without GMT in apex code

Hello All,

I'm trying to get the Date (YYYY-MM-dd) format without GMT  in apex code but no luck...some blogs are saying we can achieve thru string but i want in Date

Ex: Date --> 2020-03-06 bt i'm getting 2020-03-06 00:00:00

Regards,
VSK98
ShirishaShirisha (Salesforce Developers) 
Hi,

Can you please check the below doc for the sample code:

https://salesforce.stackexchange.com/questions/218058/datetime-formatyyyy-mm-dd-subtracts-a-day

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
sachinarorasfsachinarorasf
Hi,

I have gone through your problem.

DateTime dt = Date.today();
System.debug('dt:'+dt.format('yyyy-mm-dd'));

For more details, please follow the below link:
https://salesforce.stackexchange.com/questions/36376/how-to-convert-date-string-to-datetime-type-without-gmt


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Sachin Arora