Getting the current date

The current date can be obtained only in the timestamp format. The date of the returns funkcjatime () task planner. Close-up times can be achieved thanks to the microtime () – data returned by this function are stored a little strange, because string is returned containing separated by a space, respectively microsecond part and seconds, or „msec sec”.


Example

<?php
getmicrotime function ()
{
list ($usec, $sec) = explode („”, microtime ());
return ((float) $usec + (float) $sec);
}
?>
This information can be used to check the execution time of a script.

Example

<?php

$start = getmicrotime ();

for ($i = 0; $i <10000; $i ++) {
$str = ‚test’;
}

$end = getmicrotime ();

echo ‚<! – page generated in’. ($end  – $start). ‚ seconds -> ‚;

?>

In this way you can also check the performance of different solutions. Scripts are usually executed so quickly that a microsecond is a large unit. This limitation can be overcome by performing a specific instruction in the loop 100 or even 1,000 times, similarly as in the above example.
The function converts the date to the specified format as a parameter take timestamp date to convert. This parameter can, however, skip it and instead of a certain date it will use the current date and time. This allows you to get the current time in a format other than the timestamp.

 

Cookies help us deliver our services. By using our services, you agree to our use of cookies. More Info | Close