For getting last date of month I have written this function
/** * @param month integer value of month * @param year integer value of month * @return last day