Required Date Format dd-mm-yyyy
Hi
I have a requirment where i need to send date format in API , and the format is dd-mm-yyyy.
Is there any default date function which can give the date exactly in this format, i couldnt find any.
Instead i tried to get date, month, year separately and add it together with a '-' inbetween.
where my code fails is if the month is january, then get month will give me 1, instead i need 01.
I used string length function and added if condition to achieve this but i am unable to , can you help me out with the code.
- var_date = zoho.currentdate.getDay();
- info var_date;
- if ( var_date.length() ==1)
- {
- info "indate1";
- var_date = "0"+var_date;
- }
- var_date2 = zoho.currentdate.addday(1).getDay();
- if ( var_date2.length() ==1)
- {
- info "indate2";
- var_date2 = "0"+var_date2;
- }
- var_month = zoho.currentdate.getMonth();
- info var_month;
- info "0"+var_month;
- if ( var_month.length() ==1 )
- {
- info "inmonth";
- var_month = "0"+var_month;
- }
- var_year = zoho.currentdate.getYear();
- fromdate = var_date+"-"+var_month+"-"+var_year;
- info fromdate;
- todate = var_date2+"-"+var_month+"-"+var_year;
- info todate;