|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-10-30 11:03 UTC] jani@php.net
[2007-10-30 16:03 UTC] jpozzoli at yahoo dot com
[2007-10-30 17:12 UTC] jani@php.net
[2007-10-30 17:37 UTC] b_ulrich at t-online dot de
[2007-11-07 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 06:00:01 2025 UTC |
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