php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #26359 posix_times gives a very large value, not related with the uptime
Submitted: 2003-11-22 09:46 UTC Modified: 2004-07-26 22:06 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: whooper at dap dot ro Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.3 OS: FreeBSD 4.9
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: whooper at dap dot ro
New email:
PHP Version: OS:

 

 [2003-11-22 09:46 UTC] whooper at dap dot ro
Description:
------------
Configure Command  

FreeBSD www.dap.ro 4.9-RELEASE FreeBSD 4.9-RELEASE #0: Wed Nov i386 , Apache/1.3.28 

'./configure' '--enable-versioning' '--enable-memory-limit' '--with-layout=GNU' '--with-zlib-dir=/usr' '--disable-all' '--with-regex=php' '--with-apxs=/usr/local/sbin/apxs' '--with-bz2=/usr' '--enable-ctype' '--enable-dba' '--with-dom=/usr/local' '--enable-ftp' '--with-gd' '--enable-gd-native-ttf' '--enable-gd-jis-conv' '--with-freetype-dir=/usr/local' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-inifile' '--with-mcrypt=/usr/local' '--with-mhash=/usr/local' '--with-mime-magic=/usr/share/misc/magic.mime' '--with-mysql=/usr/local' '--with-openssl=/usr' '--enable-overload' '--with-pcre-regex=yes' '--enable-posix' '--enable-session' '--enable-sockets' '--enable-tokenizer' '--enable-xml' '--with-expat-dir=/usr/local' '--with-xmlrpc' '--enable-xslt' '--with-xslt-sablot=/usr/local' '--with-zlib=yes' '--prefix=/usr/local' 'i386-portbld-freebsd4.9'  


Loaded modules :

mod_php4, mod_setenvif, mod_so, mod_unique_id, mod_usertrack, mod_headers, mod_expires, mod_cern_meta, mod_proxy, mod_digest, mod_auth_db, mod_auth_anon, mod_auth, mod_access, mod_rewrite, mod_alias, mod_userdir, mod_speling, mod_actions, mod_imap, mod_asis, mod_cgi, mod_dir, mod_autoindex, mod_include, mod_info, mod_status, mod_negotiation, mod_mime, mod_mime_magic, mod_log_config, mod_env, mod_vhost_alias, mod_mmap_static, http_core 



Reproduce code:
---------------
<?php
function uptime() {
  $uptime = posix_times();
  // set uptime in "day hours min" format
  $upsecs = floor($uptime["ticks"]/100);
  if ($upsecs <= 3600 ){$upmins=floor($upsecs/60);
     if ( $upmins <= "9" ) {$upmins="0".$upmins;}
     $upnow=$upmins." minutes";
   } else {
     if ($upsecs <= 86400 ){
	 $uphours=floor($upsecs/3600);
	 $upmins=floor($upsecs/60 - $uphours*60);
	 if ( $upmins <= "9" ) {$upmins="0".$upmins;}
	 $upnow=$uphours." hours and ".$upmins."minutes";
     } else {
	   $updays=floor($upsecs/86400);
	   $uphours=floor($upsecs/3600 - $updays*24);
	   $upmins=floor($upsecs/60 - $uphours*60 -$updays*60*24);
	   if ( $upmins <= "9" ){$upmins="0".$upmins;}
	$upnow=$updays." days, ".$uphours." hours and ".$upmins." minutes";
      }
     }
     return $upnow;
}
?>

Expected result:
----------------
Services UpTime: 2 days, 3 hours, 15 minutes

Actual result:
--------------
Services UpTime: 0-90328 minutes

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-23 01:33 UTC] sniper@php.net
"The  function times returns the number of clock ticks that have elapsed since an arbitrary point in the past.  For  Linux  this  point  is  the moment  the system was booted.  This return value may overflow the possible range of type clock_t."

See also: 

  http://www.omc.net/cgi-bin/man.cgi?section=7&topic=clocks

This function really isn't reliable to use. Simply put: Don't use it.

 [2004-07-26 22:06 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Nov 19 11:00:01 2025 UTC