W3Schools.com

PHP gettimeofday() Function


PHP Date Reference Complete PHP Date Reference

Definition and Usage

The gettimeofday() function returns an array that contains current time information.

The meaning of the returning array keys:

  • [sec] - seconds since the Unix Epoch
  • [usec] - microseconds
  • [minuteswest] - minutes west of Greenwich
  • [dsttime] - type of dst correction

Syntax

gettimeofday(return_float)

Parameter Description
return_float Optional. Makes gettimeofday() return a float when it is set to true.


Example 1

<?php
echo(gettimeofday(true) . "<br /><br />");
print_r(gettimeofday());
?>

The output of the code above could be:

1138111447.4

Array
(
[sec] => 1138111447
[usec] => 395863
[minuteswest] => -60
[dsttime] => 0
)


Example 2

<?php
$my_t=gettimeofday();
print("$my_t[sec].$my_t[usec]");
?>

The output of the code above could be:

1138197006.988273


PHP Date Reference Complete PHP Date Reference
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE