|  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
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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: jpozzoli at yahoo dot com
New email:
PHP Version: OS:


 [2007-10-29 19:57 UTC] jpozzoli at yahoo dot com
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-30 11:03 UTC]
Please try using this CVS snapshot:
For Windows (zip):

For Windows (installer):

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.
 [2007-10-30 17:12 UTC]
Yes, but you're using an unsupported PHP version. We only support the non-patched ones you can get as sources here at 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

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: Sun May 19 05:01:33 2024 UTC