user8588: I have an arduino Uno board with a screen attached on top (http://www.freetronics.com.au/pages/16x2-lcd-shield-quickstart-guide#.VUf0tMWN0iT This is the screen). 
I'm trying to get it so that the screen displays the time in hours, minutes and seconds and counts on a 24 hours loop. Like a digital clock. I have it so that it can count but it just counts up to 99 then repeats. 
I have this code which counts milliseconds but I need minutes and hours 
    #include <Wire.h>
    #include <LiquidCrystal.h>

    LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

    void setup()
{
    lcd.begin( 16, 2 ); 
}

    void loop()
{
    lcd.setCursor ( 0, 1);
    lcd.print(millis());
}


user9849: Not sure what you're asking, but getting a Real Time Clock module will make your life a lot easier when dealing with time. Maybe post some sample code to show what your issue is. 

user8716: Well you need to break this problem down.
If you are currently able to count in milliseconds, then you know 1000 milliseconds equal 1 second, so every time the milliseconds equals 1000, you reset it to 0 and increment the seconds by 1.
You keep going from here, if seconds equals 60, then you increase minutes by 1, and reset seconds to zero.. You get the picture.

user4552: Why not trying the timer interrupt from atmega328 uC. You'll also learn something usefully and I think is more interesting than using a library and some methods ( functions) without knowing how they are implemented. 
It's really simple to make a digital clock just by interrupting every second. In ISR you'll just have to update the the values for seconds/minutes/hours. For displaying on the LCD, if you don't want to mess with LCD commands and bytes, you can use LiquidCrystal.
Example of code:(here I also used an analog pin for modifying time)
#define F_CPU   16000000UL
#include <avr/delay.h>
#include <avr/io.h>
#include <string.h>
#include <avr/interrupt.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


const short buttonPin = 5;
volatile unsigned char seconds;
volatile unsigned char minutes;
volatile unsigned char hours;
void update_clock()
{
    seconds++;
    if (seconds == 60)
    {
        seconds = 0;
        minutes++;
    }
    if(minutes==60)
    {
      minutes=0;
      hours++;
    }
    if(hours>23)
    {
      hours=0;
    }


}

ISR(TIMER1_COMPA_vect)
{

  update_clock(); 

}

void setup() 
{                



  // initialize Timer1
  pinMode(A5, INPUT_PULLUP);
  cli();          // disable global interrupts
  TCCR1A = 0;     // set entire TCCR1A register to 0
  TCCR1B = 0;     // same for TCCR1B

  // set compare match register to desired timer count:
  OCR1A = 15624;
  // turn on CTC mode:
  TCCR1B |= (1 << WGM12);
  // Set CS10 and CS12 bits for 1024 prescaler:
  TCCR1B |= (1 << CS10);
  TCCR1B |= (1 << CS12);
  // enable timer compare interrupt:
  TIMSK1 |= (1 << OCIE1A);
  sei();          // enable global interrupts
  lcd.begin(16, 2);
  lcd.print("HH:MM:SS");
  Serial.begin(9600); 


}

void display_on_lcd()
{

  lcd.setCursor(0, 1);
  lcd.print(hours);
  lcd.setCursor(2,1);
  lcd.print(":");
  lcd.setCursor(3,1);  
  lcd.print(minutes);
  lcd.setCursor(5,1);
  lcd.print(":");
  lcd.setCursor(6,1);
  lcd.print(seconds);


}


void loop()
{

  display_on_lcd();

  Serial.println(analogRead(5));
  if(analogRead(buttonPin)<1000)
  {
    if(minutes==59)
    {
      minutes=0;
      if(hours==23)
        hours=0;
      else
        hours++;
    }
    else
    {
      minutes++;
    }
  }


}

Just search and you'll find a lot of examples. 

user8588: Thanks everyone for your help! I've ended up with the code below which works quite well, there's the odd glitch with the seconds which is for some reason fixed if milliseconds is added on the end, but other than that it works very well.
#include <Wire.h>
#include <LiquidCrystal.h>

#define MILLIS_OVERFLOW 34359738

/**
* Clock Variables
*/
unsigned long currentMillis, previousMillis, elapsedMillis;
int seconds, minutes, hours;

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup()
{
  Serial.begin(9600);
  lcd.begin( 16, 2 ); 

}

void loop()
{
    setClock();
    /**
   * After set clock now you have 3 int variables with the current time
   */
   //seconds
   //minutes
   //hours
     lcd.setCursor ( 0, 1);
     lcd.print(hours);
     lcd.print(":");
     lcd.print(minutes);
     lcd.print(":");
     lcd.print(seconds);
     lcd.print(":");
     lcd.print(elapsedMillis);

}

void setClock()
{
    currentMillis = millis();
    /**
     * The only moment when currentMillis will be smaller than            previousMillis
     * will be when millis() oveflows
    */
    if (currentMillis < previousMillis){
    elapsedMillis += MILLIS_OVERFLOW - previousMillis + currentMillis;
} else {
    elapsedMillis += currentMillis - previousMillis;
}

/**
 * If we use equals 1000 its possible that because of the mentioned loop limitation
 * you check the difference when its value is (999) and on the next loop its value is (1001)
 */
if (elapsedMillis > 999){
    seconds++;
    elapsedMillis = elapsedMillis - 1000;
}

if (seconds == 60){
    minutes++;
    seconds = 0;
}
if (minutes == 60){
    hours++;
    minutes = 0;
}
if (hours == 24){
    hours = 0;
}

previousMillis = currentMillis;
}


user7508: The takeaway from the previous answers is that your best option is to
use an RTC (real-time clock). Failing that, you can emulate the RTC
using millis(), at the cost of a significant drift, especially if your
Arduino is clocked off a ceramic resonator.
I would just like to add that you do not have to write the logic of that
millis()-based “soft RTC” yourself, as this has already implemented in
the RTC_Millis class from Adafruit's RTClib:
#include <RTClib.h>
#include <LiquidCrystal.h>

RTC_Millis rtc;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
    rtc.begin(DateTime(F(__DATE__), F(__TIME__)));
    lcd.begin(16, 2);
}

void loop() {
    static DateTime last_time_printed;
    DateTime now = rtc.now();
    if (now != last_time_printed) {
        lcd.setCursor(0, 1);
        lcd.print(now.timestamp(DateTime::TIMESTAMP_TIME));
        last_time_printed = now;
    }
}

One nice thing about this option is that, if you later opt for a real
RTC, you will only need to do minimal changes to your code. Another nice
thing is that, if you measure the drift of your clock, you can easily
correct it: just replace RTC_Millis with RTC_Micros
and call rtc.adjustDrift() in setup(). You will be able to adjust
the drift with a 1 ppm resolution. Note that both RTC_Millis
and RTC_Micros are immune to rollover problems.

user6834: Others mention a Real-Time Clock (RTC), and it may look like the obvious choice, but maybe it isn't. All a RTC does is keep counters for hours, minutes, seconds, date and month, but your microcontroller can do that as well.
Unfortunately the Uno doesn't have a crystal, but a ceramic resonator, which isn't nearly as accurate. Not that it matters much, even a crystal-based RTC may deviate several seconds a day. You can measure the error over a long time, and correct at regular times in software, but this is tedious.
If you want long-time accuracy there are two cheap ways:

use an atomic clock receiver. In Europe there's DCF77, in North-America it's WWVB which broadcasts very accurate date and time information. A receiver module for these costs around 10 dollar
use the mains frequency to clock your clock. On the long term this is extremely accurate (just think about your alarm clock: how often do you have to adjust that?) In Europe you would count 100 half periods per second (120 in the US). When your counter reaches that count, reset it and increment the seconds. If seconds reaches 60, reset it and increment minutes. And so on. If you're not exactly electronics-savvy you can ask on electronics.stackexchange.com to help you out. It's not difficult.


user4438: Im with @arvid-jense on this one, if you are working on a serious Digital Clock, then you should get the Real Time Clock.
Now if you are learning Arduino and want to play with your LCD Minidisplay and build a clock, you must know some important limitations of the millis() function on this project:

The mills function will overflow, after approximately 50 days.
Your clock will be inexact because the cycles of the Arduino
loop, you will be checking how much mills has passed on each loop.
(it will be lagging ~ 10 seconds each day, so on day 7 you will be one minute late)
the parameter for millis is an unsigned long, errors may be generated
if a programmer tries to do math with other datatypes such as ints.

That being said
#include <Wire.h>
#include <LiquidCrystal.h>

/**
 * Clock Variables
 */
unsigned long currentMillis, previousMillis, elapsedMillis;
int seconds, minutes, hours;

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup()
{
    lcd.begin( 16, 2 ); 
}

void loop()
{
    setClock();
    /**
     * After set clock now you have 3 int variables with the current time
     */
     //seconds
     //minutes
     //hours
     lcd.setCursor ( 0, 1);
     lcd.print(millis());
}

void setClock()
{
    currentMillis = millis();
    elapsedMillis += currentMillis - previousMillis;

    /**
     * If we use equals 1000 its possible that because of the mentioned loop limitation
     * you check the difference when its value is (999) and on the next loop its value is (1001)
     */
    if (elapsedMillis > 999){
        seconds++;
        elapsedMillis = elapsedMillis - 1000;
    }

    if (seconds == 60){
        minutes++;
        seconds = 0;
    }
    if (minutes == 60){
        hours++;
        minutes = 0;
    }
    if (hours == 24){
        hours = 0;
    }

    previousMillis = currentMillis;
}

Nice tutorial on building an Alarm Clock

8588: <p>I have an arduino Uno board with a screen attached on top (<a href="http://www.freetronics.com.au/pages/16x2-lcd-shield-quickstart-guide#.VUf0tMWN0iT" rel="nofollow">http://www.freetronics.com.au/pages/16x2-lcd-shield-quickstart-guide#.VUf0tMWN0iT</a> This is the screen). </p>

<p>I'm trying to get it so that the screen displays the time in hours, minutes and seconds and counts on a 24 hours loop. Like a digital clock. I have it so that it can count but it just counts up to 99 then repeats. </p>

<p>I have this code which counts milliseconds but I need minutes and hours </p>

<pre><code>    #include &lt;Wire.h&gt;
    #include &lt;LiquidCrystal.h&gt;

    LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

    void setup()
{
    lcd.begin( 16, 2 ); 
}

    void loop()
{
    lcd.setCursor ( 0, 1);
    lcd.print(millis());
}
</code></pre>
 9849: <p>Not sure what you're asking, but getting a Real Time Clock module will make your life a lot easier when dealing with time. Maybe post some sample code to show what your issue is. </p>
 8716: <p>Well you need to break this problem down.</p>

<p>If you are currently able to count in milliseconds, then you know 1000 milliseconds equal 1 second, so every time the milliseconds equals 1000, you reset it to 0 and increment the seconds by 1.</p>

<p>You keep going from here, if seconds equals 60, then you increase minutes by 1, and reset seconds to zero.. You get the picture.</p>
 4552: <p>Why not trying the timer interrupt from atmega328 uC. You'll also learn something usefully and I think is more interesting than using a library and some methods ( functions) without knowing how they are implemented. </p>

<p>It's really simple to make a digital clock just by interrupting every second. In ISR you'll just have to update the the values for seconds/minutes/hours. For displaying on the LCD, if you don't want to mess with LCD commands and bytes, you can use LiquidCrystal.</p>

<p>Example of code:(here I also used an analog pin for modifying time)</p>

<pre><code>#define F_CPU   16000000UL
#include &lt;avr/delay.h&gt;
#include &lt;avr/io.h&gt;
#include &lt;string.h&gt;
#include &lt;avr/interrupt.h&gt;
#include &lt;LiquidCrystal.h&gt;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


const short buttonPin = 5;
volatile unsigned char seconds;
volatile unsigned char minutes;
volatile unsigned char hours;
void update_clock()
{
    seconds++;
    if (seconds == 60)
    {
        seconds = 0;
        minutes++;
    }
    if(minutes==60)
    {
      minutes=0;
      hours++;
    }
    if(hours&gt;23)
    {
      hours=0;
    }


}

ISR(TIMER1_COMPA_vect)
{

  update_clock(); 

}

void setup() 
{                



  // initialize Timer1
  pinMode(A5, INPUT_PULLUP);
  cli();          // disable global interrupts
  TCCR1A = 0;     // set entire TCCR1A register to 0
  TCCR1B = 0;     // same for TCCR1B

  // set compare match register to desired timer count:
  OCR1A = 15624;
  // turn on CTC mode:
  TCCR1B |= (1 &lt;&lt; WGM12);
  // Set CS10 and CS12 bits for 1024 prescaler:
  TCCR1B |= (1 &lt;&lt; CS10);
  TCCR1B |= (1 &lt;&lt; CS12);
  // enable timer compare interrupt:
  TIMSK1 |= (1 &lt;&lt; OCIE1A);
  sei();          // enable global interrupts
  lcd.begin(16, 2);
  lcd.print("HH:MM:SS");
  Serial.begin(9600); 


}

void display_on_lcd()
{

  lcd.setCursor(0, 1);
  lcd.print(hours);
  lcd.setCursor(2,1);
  lcd.print(":");
  lcd.setCursor(3,1);  
  lcd.print(minutes);
  lcd.setCursor(5,1);
  lcd.print(":");
  lcd.setCursor(6,1);
  lcd.print(seconds);


}


void loop()
{

  display_on_lcd();

  Serial.println(analogRead(5));
  if(analogRead(buttonPin)&lt;1000)
  {
    if(minutes==59)
    {
      minutes=0;
      if(hours==23)
        hours=0;
      else
        hours++;
    }
    else
    {
      minutes++;
    }
  }


}
</code></pre>

<p>Just search and you'll find a lot of examples. </p>
 8588: <p>Thanks everyone for your help! I've ended up with the code below which works quite well, there's the odd glitch with the seconds which is for some reason fixed if milliseconds is added on the end, but other than that it works very well.</p>

<pre><code>#include &lt;Wire.h&gt;
#include &lt;LiquidCrystal.h&gt;

#define MILLIS_OVERFLOW 34359738

/**
* Clock Variables
*/
unsigned long currentMillis, previousMillis, elapsedMillis;
int seconds, minutes, hours;

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup()
{
  Serial.begin(9600);
  lcd.begin( 16, 2 ); 

}

void loop()
{
    setClock();
    /**
   * After set clock now you have 3 int variables with the current time
   */
   //seconds
   //minutes
   //hours
     lcd.setCursor ( 0, 1);
     lcd.print(hours);
     lcd.print(":");
     lcd.print(minutes);
     lcd.print(":");
     lcd.print(seconds);
     lcd.print(":");
     lcd.print(elapsedMillis);

}

void setClock()
{
    currentMillis = millis();
    /**
     * The only moment when currentMillis will be smaller than            previousMillis
     * will be when millis() oveflows
    */
    if (currentMillis &lt; previousMillis){
    elapsedMillis += MILLIS_OVERFLOW - previousMillis + currentMillis;
} else {
    elapsedMillis += currentMillis - previousMillis;
}

/**
 * If we use equals 1000 its possible that because of the mentioned loop limitation
 * you check the difference when its value is (999) and on the next loop its value is (1001)
 */
if (elapsedMillis &gt; 999){
    seconds++;
    elapsedMillis = elapsedMillis - 1000;
}

if (seconds == 60){
    minutes++;
    seconds = 0;
}
if (minutes == 60){
    hours++;
    minutes = 0;
}
if (hours == 24){
    hours = 0;
}

previousMillis = currentMillis;
}
</code></pre>
 7508: <p>The takeaway from the previous answers is that your best option is to
use an RTC (real-time clock). Failing that, you can emulate the RTC
using <code>millis()</code>, at the cost of a significant drift, especially if your
Arduino is clocked off a ceramic resonator.</p>

<p>I would just like to add that you do not have to write the logic of that
<code>millis()</code>-based “soft RTC” yourself, as this has already implemented in
the <a href="https://adafruit.github.io/RTClib/html/class_r_t_c___millis.html" rel="nofollow noreferrer"><code>RTC_Millis</code> class</a> from <a href="https://github.com/adafruit/RTClib" rel="nofollow noreferrer">Adafruit's RTClib</a>:</p>

<pre class="lang-cpp prettyprint-override"><code>#include &lt;RTClib.h&gt;
#include &lt;LiquidCrystal.h&gt;

RTC_Millis rtc;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
    rtc.begin(DateTime(F(__DATE__), F(__TIME__)));
    lcd.begin(16, 2);
}

void loop() {
    static DateTime last_time_printed;
    DateTime now = rtc.now();
    if (now != last_time_printed) {
        lcd.setCursor(0, 1);
        lcd.print(now.timestamp(DateTime::TIMESTAMP_TIME));
        last_time_printed = now;
    }
}
</code></pre>

<p>One nice thing about this option is that, if you later opt for a real
RTC, you will only need to do minimal changes to your code. Another nice
thing is that, if you measure the drift of your clock, you can easily
correct it: just replace <code>RTC_Millis</code> with <a href="https://adafruit.github.io/RTClib/html/class_r_t_c___micros.html" rel="nofollow noreferrer"><code>RTC_Micros</code></a>
and call <code>rtc.adjustDrift()</code> in <code>setup()</code>. You will be able to adjust
the drift with a 1&nbsp;<a href="https://en.wikipedia.org/wiki/Parts-per_notation" rel="nofollow noreferrer">ppm</a> resolution. Note that both <code>RTC_Millis</code>
and <code>RTC_Micros</code> are immune to rollover problems.</p>
 6834: <p>Others mention a Real-Time Clock (RTC), and it may look like the obvious choice, but maybe it isn't. All a RTC does is keep counters for hours, minutes, seconds, date and month, but your microcontroller can do that as well.<br>
Unfortunately the Uno doesn't have a crystal, but a ceramic resonator, which isn't nearly as accurate. Not that it matters much, even a crystal-based RTC may deviate several seconds a day. You can measure the error over a long time, and correct at regular times in software, but this is tedious.</p>

<p>If you want long-time accuracy there are two cheap ways:</p>

<ol>
<li>use an atomic clock receiver. In Europe there's DCF77, in North-America it's WWVB which broadcasts very accurate date and time information. A receiver module for these costs around 10 dollar</li>
<li>use the mains frequency to clock your clock. On the long term this is extremely accurate (just think about your alarm clock: how often do you have to adjust that?) In Europe you would count 100 half periods per second (120 in the US). When your counter reaches that count, reset it and increment the seconds. If seconds reaches 60, reset it and increment minutes. And so on. If you're not exactly electronics-savvy you can ask on <a href="http://electronics.stackexchange.com">electronics.stackexchange.com</a> to help you out. It's not difficult.</li>
</ol>
 4438: <p>Im with @arvid-jense on this one, if you are working on a serious Digital Clock, then you should get the Real Time Clock.</p>

<p>Now if you are learning Arduino and want to play with your LCD Minidisplay and build a clock, you must know some important limitations of the <a href="http://www.arduino.cc/en/Reference/Millis" rel="nofollow">millis()</a> function on this project:</p>

<ul>
<li>The mills function will overflow, after approximately 50 days.</li>
<li>Your clock will be <strong>inexact</strong> because the cycles of the Arduino
loop, you will be checking how much mills has passed on each loop.
<em>(it will be lagging ~ 10 seconds each day, so on day 7 you will be one minute late)</em></li>
<li>the parameter for millis is an unsigned long, errors may be generated
if a programmer tries to do math with other datatypes such as ints.</li>
</ul>

<p>That being said</p>

<pre><code>#include &lt;Wire.h&gt;
#include &lt;LiquidCrystal.h&gt;

/**
 * Clock Variables
 */
unsigned long currentMillis, previousMillis, elapsedMillis;
int seconds, minutes, hours;

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup()
{
    lcd.begin( 16, 2 ); 
}

void loop()
{
    setClock();
    /**
     * After set clock now you have 3 int variables with the current time
     */
     //seconds
     //minutes
     //hours
     lcd.setCursor ( 0, 1);
     lcd.print(millis());
}

void setClock()
{
    currentMillis = millis();
    elapsedMillis += currentMillis - previousMillis;

    /**
     * If we use equals 1000 its possible that because of the mentioned loop limitation
     * you check the difference when its value is (999) and on the next loop its value is (1001)
     */
    if (elapsedMillis &gt; 999){
        seconds++;
        elapsedMillis = elapsedMillis - 1000;
    }

    if (seconds == 60){
        minutes++;
        seconds = 0;
    }
    if (minutes == 60){
        hours++;
        minutes = 0;
    }
    if (hours == 24){
        hours = 0;
    }

    previousMillis = currentMillis;
}
</code></pre>

<p><a href="http://www.instructables.com/id/Arduino-Binary-Alarm-Clock/#step1" rel="nofollow">Nice tutorial on building an Alarm Clock</a></p>
