Actually the library, Time.h, can be quite helpful. But you don't need it if all you want is to get hours and minutes (and seconds, etc.) from an RTC that has been set already. Setting the RTC is another topic.
Last summer, I wrote a demonstration sketch that reads the hours, minutes and seconds from an RTC using I2C (and the Wire.h library) and sends it to the serial monitor. The demo assumes that you are using a UNO and an RTC breakout that has 4 connectors, SDA, SCL, GND and VIN. Perhaps you could modify this code to do what you want (which I am not quite clear on.) Just upload this sketch and open the serial monitor window:
/*
Simplest clock with RTC, output to serial
061316 Chris101 4106 bytes flash and 412 bytes RAM on a UNO
Connect A4 on the UNO to SDA on the RTC
" A5 " " " " SCL " " "
" GND " " " " GND " " "
" 5V " " " " VIN " " "
Upload and open the serial monitor window.
Assuming the time has been set on the RTC,
the hours:minutes:seconds will scroll down
the serial monitor window, one line a second.
*/
#include "Wire.h"
#define rtcAddress 0x68
unsigned long previousSecondMillis;
const long oneSecond = 1000UL;
void setup()
{
Wire.begin();
Serial.begin(9600);
previousSecondMillis = millis();
}
void loop() {
if (millis() - previousSecondMillis >= oneSecond) {
previousSecondMillis += oneSecond; // do this once a second
// get bcd data from the rtc
Wire.beginTransmission(rtcAddress); // 0x68 is DS3231 device address
Wire.write((byte)0); // start at register 0
Wire.endTransmission();
Wire.requestFrom(rtcAddress, 3); // request three bytes (seconds, minutes, hours)
while (Wire.available())
{
byte seconds = Wire.read(); // get seconds
byte minutes = Wire.read(); // get minutes
byte hours = Wire.read(); // get hours
// convert BCD to decimal: (number & 0b11110000) is the 'tens place' digit
// and (number & 0b00001111) is the 'ones place' digit
// of a two digit, decimal number (as are the hours, minutes and seconds)
seconds = ((seconds & 0b11110000) >> 4) * 10 + (seconds & 0b00001111);
minutes = ((minutes & 0b11110000) >> 4) * 10 + (minutes & 0b00001111);
hours = ((hours & 0b00110000) >> 4) * 10 + (hours & 0b00001111);
// serial.print the bcd values
Serial.print(hours);
Serial.print(':');
Serial.print(minutes);
Serial.print(':');
Serial.println(seconds);
}
}
}