Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Hi All,
i want to convert system date to mm/dd/yyyy format in controller.Any one can you please help me this.
Thanks in advance.
convert the date into string & u can do what ever u want with string
Hi,
Try the below code snippet as reference:
date tt=system.today();
string ss=tt.format();
system.debug('#########3'+ss);
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
You can convert the dateTime to specific date format using the below method
DateTime d = Date.Today() ;String dateStr = d.format('dd/MM/yyyy') ;
and you can covert the date to dateTime using
Date dToday = System.Today(); Datetime dt = datetime.newInstance(dToday.year(), dToday.month(),dToday.day());
Let me know if you need anything else
Hi
Use format to convert System date to as u like.
datetime dt = system.today();string st=dt.format();system.debug(st);
Regards,
Rajesh.
convert the date into string & u can do what ever u want with string
Hi,
Try the below code snippet as reference:
date tt=system.today();
string ss=tt.format();
system.debug('#########3'+ss);
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
You can convert the dateTime to specific date format using the below method
DateTime d = Date.Today() ;
String dateStr = d.format('dd/MM/yyyy') ;
and you can covert the date to dateTime using
Date dToday = System.Today();
Datetime dt = datetime.newInstance(dToday.year(), dToday.month(),dToday.day());
Let me know if you need anything else
Hi
Use format to convert System date to as u like.
datetime dt = system.today();
string st=dt.format();
system.debug(st);
Regards,
Rajesh.
Date d = Date.today();
String dTXT = d.format();
system.debug('!!! dTXT ' + dTXT); //display date like: dd/mm/yyyy
system.debug('!!! new date ' + cleanDate(dTXT));
public String cleanDate(String theDate){
String [] s = theDate.split('/');
String newDate= '';
if(s[0].length() == 1){
newDate = '0'+s[0];
}else{
newDate = s[0];
}
newDate = s[1]+'/'+newDate+'/'+s[2];
return newDate;
}