use GNU date (part of GNU sh-utils) with:
date --date=tomorrow +%d
or use mktime (http://www.weirdways.com/technogeek/source/mktime/index.html)
mktime -d +1 -F %d
FYI, You can also use mktime to directly discover what the last day of the current month is:
mktime -m +1 -d 0 -F %d
Ken Pizzini