You can use the millis function, which is the number of milliseconds since the Arduino was powered or, or the millis counter resets (every 54 days or so). To get the number of seconds, divide by 1000. From there you divide by 60 to get number of minutes, etc. You will have to account for months, and ultimately leap years.
You can get real time clocks with their own battery that you can attach to your Arduino to keep track of time even when the Arduino is powered off. One such vendor is: http://arduino-direct.com/sunshop/index.php?l=product_detail&p=278.
If you have a GPS unit attached, the GPS stream includes an accurate time stream.
If your arduino is connected to the internet either via the ethernet sheild or a wifi shield, it can presumably do a network time request to get the initial time when booting up.