#43132 [Com]: Date returned from exec command is formatted
| From: | b_ulrich at t-online dot de | Date: | Tue, 30 Oct 2007 17:37:16 +0000 |
| Subject: | #43132 [Com]: Date returned from exec command is formatted | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-119093@lists.php.net to get a copy of this message | ||
ID: 43132
Comment by: b_ulrich at t-online dot de
Reported By: jpozzoli at yahoo dot com
Status: Feedback
Bug Type: CGI related
Operating System: Debian Linux 2.6.18-5-686
PHP Version: 5.2.0
New Comment:
This isn't a Bug.
If you take a look at the documentation for who you will find:
Time stamps are listed according to the time zone rules specified by
the
TZ' environment variable, or by the system default rules if TZ'
is not set. *Note Specifying the Time Zone with `TZ': (libc)TZ
Variable.
It seems that the environment of the user wich runs the Apache is
different from the environment of your putty user...
Previous Comments:
------------------------------------------------------------------------
[2007-10-30 17:12:18] jani@php.net
Yes, but you're using an unsupported PHP version. We only support the
non-patched ones you can get as sources here at php.net. Some distros
patch their PHP binaries (and often badly) so..
------------------------------------------------------------------------
[2007-10-30 16:03:29] jpozzoli at yahoo dot com
I'll get the CVS, but just for your reference, here's a composite of
several screens showing this "error", with the actual PHP code in the
box to the right.
http://www.flipnut.com/php-bug-43132.jpg
------------------------------------------------------------------------
[2007-10-30 11:03:41] jani@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
I can't reproduce this.
------------------------------------------------------------------------
[2007-10-29 19:57:00] jpozzoli at yahoo dot com
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 this bug report at http://bugs.php.net/?id=43132&edit=1