Required Date Format dd-mm-yyyy

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.
  1. var_date = zoho.currentdate.getDay();
  2. info var_date;
  3. if ( var_date.length() ==1) 
  4. {
  5. info "indate1";
  6. var_date = "0"+var_date;
  7. }
  8. var_date2 = zoho.currentdate.addday(1).getDay();
  9. if ( var_date2.length() ==1) 
  10. {
  11. info "indate2";
  12. var_date2 = "0"+var_date2;
  13. }
  14. var_month = zoho.currentdate.getMonth();
  15. info var_month;
  16. info "0"+var_month;
  17. if ( var_month.length() ==1 )
  18. {
  19. info "inmonth";
  20. var_month = "0"+var_month;
  21. }
  22. var_year = zoho.currentdate.getYear();
  23. fromdate  = var_date+"-"+var_month+"-"+var_year;
  24. info fromdate;
  25. todate = var_date2+"-"+var_month+"-"+var_year;
  26. info todate;