From:             jpozzoli at yahoo dot com
Operating system: Debian Linux 2.6.18-5-686
PHP version:      5.2.4
PHP Bug Type:     CGI related
Bug description:  Date returned from exec command is formatted

Description:
------------
This is on Debian PHP version 5.2.0-8+etch7 running on Apache/2.2.3 


When trying to get the last reboot date of a linux server, from the
command line I run "who -b". More precisely, I run "who -b|awk \'{print $3"
"$4}\'" which, on the CLI, returns "2007-10-18 04:45". When I run the PHP
command echo exec('who -b|awk \'{print $3" "$4}\''); I get the following
result: Oct 18

Obviously, this has been formatted by PHP.

To make sure of this, I tried this:
$rebootdate = strftime("%m-%d-%Y %I:%M%p", strtotime($rebootdateexec));

This get's closer. It outputs "10-18-2007 12:00AM". So it got the date but
missed the time.

Reproduce code:
---------------
$rebootdateexec = exec('who -b|awk \'{print $3" "$4}\'');

echo $rebootdateexec;

$rebootdate = strftime("%m-%d-%Y %I:%M%p", strtotime($rebootdateexec));

echo $rebootdate;

Expected result:
----------------
$rebootdateexec = 2007-10-18 04:45

$rebootdate = 10-18-2007 04:45AM

Actual result:
--------------
$rebootdateexec = Oct 18

$rebootdate = 10-18-2007 12:00AM

-- 
Edit bug report at http://bugs.php.net/?id=43132&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43132&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43132&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43132&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43132&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43132&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43132&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43132&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43132&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43132&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43132&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43132&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43132&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43132&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43132&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43132&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43132&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43132&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43132&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43132&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43132&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43132&r=mysqlcfg

Reply via email to