Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

%w Day of the week as a number with Sunday being zero
%x Preferred date representation


%X Preferred time representation
%y Two-digit year with zero-fill
%Y Four-digit year
%Z Time zone
%% A literal % character


string microtime()


The microtime function returns a string with two numbers separated by a space. The first
number is microseconds on the system clock. The second is the number of seconds since
January 1, 1970.


<?
//print microtime
print("Start: ". microtime(). "
\n");


//sleep for a random time
usleep(rand(100,5000));


//print microtime
print("Stop: ". microtime(). "
\n");
?>


integer mktime(integer hour, integer minute, integer second,
integer month, integer day, integer year)


The mktime function returns a timestamp for a given date, the number of seconds since
January 1, 1970. All the arguments are optional and, if left out, the appropriate value for
the current time will be used. If an argument is out of range, mktime will account for the
surplus or deficit by modifying the other time units. For example, using 13 for the month
argument is equivalent to January of the following year. This makes mktime an effective
tool for adding arbitrary time to a date.


<?
print("Fifty Hours from Now: ");
print(date("h:i A l F dS, Y", mktime(date("h")+50)));
print("
\n");
?>


string strftime(string format, integer timestamp)

Free download pdf