Visit the Official PHP Website

Search this Site

PHP Programming

By James N Hitz

The time() function

time() on the other hand is a PHP function that returns the time according to the server's system clock in UNIX Epoch time. Epoch time is a method of representing time in seconds counting from January 1 1970 00:00:00 GMT. Since we are counting in seconds then one hour is 3600 (60 x 60) seconds, and one day is 86400(60 x 60 x 24) seconds and one year 29030400. Figure out how old you are in seconds and ask for your pension!

That's all. If you always log user activities depending on the entries they make, then you can use time() to timestamp these activities. Using time() is straight forward:

$epochTime = time();
print $epochTime;

On my computer, this printed:

989937415

This indicates that I had run this script exactly 989937415 seconds after Epoch. And yet on the previous day it had printed 989851015. Time really does fly wouldn't you agree?

<< The checkdate() function | The mktime() function >>

JamHitz Productions