Time
All fab things time
PHP:
Elasped time
Last updated at 02:38 PM on Monday 27th August, 2007 by Administrator
<?
$startTime = microtime(true);
// Something happens here
$endTime = microtime(true);
$elapsedTimeInSeconds = ($startTime - $endTime) / 1000;
?>
With PHP 5, the $_SERVER['REQUEST_TIME'] environment variable can also be used to calculate the elapsed time since the HTTP request was made to your php page.
<?
$timeSinceRequest = $_SERVER['REQUEST_TIME'] - microtime(true);
?>
Comments (0)
Format time
Last updated at 03:18 PM on Monday 27th August, 2007 by Administrator
Formatting date-time using the date()[uk2.php.net] function.
/*
Example: 10:57 PM on Monday 21 May, 2007
h - 12-hour format of an hour with leading zeros (01 through 12)
i - Minutes with leading zeros (00 to 59)
A - AM/PM
l - A full textual representation of the day of the week (Sunday - Saturday)
j - Day of the month without leading zeros (1 to 31)
S - English ordinal suffix for the day of the month, 2 characters (st, nd, rd or th)
F - A full textual representation of a month (January or March)
Y - A full numeric representation of a year, 4 digits (1999 or 2003)
*/
$format = 'h:i A \o\n l jS F, Y';
// Format date/time NOW
date($format);
// Or format a specific date/time
date($format, $timestamp);
Comments (0)