php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43132 Date returned from exec command is formatted
Submitted: 2007-10-29 19:57 UTC Modified: 2007-11-07 01:00 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: jpozzoli at yahoo dot com Assigned:
Status: No Feedback Package: CGI/CLI related
PHP Version: 5.2.0 OS: Debian Linux 2.6.18-5-686
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: jpozzoli at yahoo dot com
New email:
PHP Version: OS:

 

 [2007-10-29 19:57 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-30 11:03 UTC] 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-30 16:03 UTC] 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 17:12 UTC] 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 17:37 UTC] b_ulrich at t-online dot de
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...
 [2007-11-07 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 18:01:30 2024 UTC