Setting the time RTC DS1307

I have a DS1307 RTC that is working great.
I only use the hours and minutes and set the time in the code:

rtc.adjust(DateTime(__DATE__, "16:30:00"));

I want to be able to set the time with the program running,
but I can't figure out how to replace the "16:30:00" with variables.

but I can't figure out how to replace the "16:30:00" with variables.

The DateTime() function expects a string. You can create the string using sprintf(). Or, you can call rtc.adjust() using a different overload that takes year, month, day, hour, minutes, and seconds.

Thanks for sending me in the right direction :slight_smile:
This worked setting the time to "15:40"

char setTimeChar[ ] = "23:59:59";
int setHours = 15;
int setMinutes = 40;
setTimeChar[0] = (setHours/10)+'0';
setTimeChar[1] = (setHours%10)+'0';
setTimeChar[3] = (setMinutes/10)+'0';
setTimeChar[4] = (setMinutes%10)+'0';
rtc.adjust(DateTime("Dec 13 2013", setTimeChar));