Bug #67204 [NEW]: In midnight,date("h") return 12,is it correct?
| From: | zws at ahtvu dot ah dot cn | Date: | Mon, 05 May 2014 03:36:14 +0000 |
| Subject: | Bug #67204 [NEW]: In midnight,date("h") return 12,is it correct? | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-185623@lists.php.net to get a copy of this message | ||
From: zws at ahtvu dot ah dot cn
Operating system: Linux
PHP version: Irrelevant
Package: Date/time related
Bug Type: Bug
Bug description:In midnight,date("h") return 12,is it correct?
Description:
------------
When I browse cacti.log, I find some date information are strange. I
list them bellow.
05/04/2014 11:55:17 PM - SPINE: Poller[0] Host[25] TH[1] DS[525]
WARNING: SNMP timeout detected [2000 ms], ignoring host '10.1.10.12'
05/04/2014 11:55:25 PM - SPINE: Poller[0] Host[25] TH[1] DS[525]
WARNING: SNMP timeout detected [2000 ms], ignoring host '10.1.10.12'
05/04/2014 11:56:28 PM - SYSTEM STATS: Time:86.5674 Method:spine
Processes:1 Threads:1 Hosts:84 HostsPerProcess:84 DataSources:4237
RRDsProcessed:1129
05/04/2014 11:56:28 PM - SYSTEM THOLD STATS: Time:0.0173 Tholds:1
DownHosts:0
05/04/2014 11:56:28 PM - WEATHERMAP: Poller[0] Weathermap 0.97c starting
- Normal logging mode. Turn on DEBUG in Cacti for more information
05/04/2014 11:56:28 PM - WEATHERMAP: Poller[0] STATS: Weathermap 0.97c
run complete - Sun, 04 May 14 23:56:28 +0800: 0 maps were run in 0
seconds with 0 warnings.
05/05/2014 12:01:18 AM - SYSTEM STATS: Time:77.6253 Method:spine
Processes:1 Threads:1 Hosts:84 HostsPerProcess:84 DataSources:4237
RRDsProcessed:1124
05/05/2014 12:01:18 AM - SYSTEM THOLD STATS: Time:0.0188 Tholds:1
DownHosts:0
05/05/2014 12:01:18 AM - WEATHERMAP: Poller[0] Weathermap 0.97c starting
- Normal logging mode. Turn on DEBUG in Cacti for more information
05/05/2014 12:01:18 AM - WEATHERMAP: Poller[0] STATS: Weathermap 0.97c
run complete - Mon, 05 May 14 00:01:18 +0800: 0 maps were run in 0
seconds with 0 warnings.
05/05/2014 12:05:17 AM - SPINE: Poller[0] Host[25] Hostname[10.1.10.12]
ERROR: HOST EVENT: Host is DOWN Message: Host did not respond to SNMP
05/05/2014 12:06:19 AM - SYSTEM STATS: Time:78.5439 Method:spine
Processes:1 Threads:1 Hosts:84 HostsPerProcess:84 DataSources:4237
RRDsProcessed:1124
05/05/2014 12:06:19 AM - SYSTEM THOLD STATS: Time:0.0186 Tholds:1
DownHosts:0
05/05/2014 12:06:19 AM - WEATHERMAP: Poller[0] Weathermap 0.97c starting
- Normal logging mode. Turn on DEBUG in Cacti for more information
.....................#ommit
05/05/2014 12:51:28 AM - WEATHERMAP: Poller[0] STATS: Weathermap 0.97c
run complete - Mon, 05 May 14 00:51:28 +0800: 0 maps were run in 0
seconds with 0 warnings.
05/05/2014 12:56:19 AM - SYSTEM STATS: Time:78.3940 Method:spine
Processes:1 Threads:1 Hosts:84 HostsPerProcess:84 DataSources:4237
RRDsProcessed:1124
05/05/2014 12:56:19 AM - SYSTEM THOLD STATS: Time:0.0189 Tholds:1
DownHosts:0
05/05/2014 12:56:19 AM - WEATHERMAP: Poller[0] Weathermap 0.97c starting
- Normal logging mode. Turn on DEBUG in Cacti for more information
05/05/2014 12:56:19 AM - WEATHERMAP: Poller[0] STATS: Weathermap 0.97c
run complete - Mon, 05 May 14 00:56:19 +0800: 0 maps were run in 0
seconds with 0 warnings.
05/05/2014 01:00:19 AM - SPINE: Poller[0] Host[25] TH[1] DS[252]
WARNING: SNMP timeout detected [2000 ms], ignoring host '10.1.10.12'
05/05/2014 01:00:19 AM - SPINE: Poller[0] Host[25] TH[1] DS[252]
WARNING: SNMP timeout detected [2000 ms], ignoring host '10.1.10.12'
05/05/2014 01:00:19 AM - SPINE: Poller[0] Host[25] TH[1] DS[519]
WARNING: SNMP timeout detected [2000 ms], ignoring host '10.1.10.12'
05/05/2014 01:00:19 AM - SPINE: Poller[0] Host[25] TH[1] DS[519]
WARNING: SNMP timeout detected [2000 ms], ignoring host '10.1.10.12'
The date column is
05/04/2014 11:56:28 PM
...
05/05/2014 12:01:18 AM
....
05/05/2014 01:00:19 AM
It should be wrong,so I do some test to confirm it.
[root@CactiEZ ~]# uname -a
Linux CactiEZ.local 2.6.32-71.el6.i686 #1 SMP Fri Nov 12 04:17:17 GMT
2010 i686 i686 i386 GNU/Linux
[root@CactiEZ ~]# php -v
PHP 5.3.2 (cli) (built: Nov 12 2010 08:16:13)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
[root@CactiEZ ~]# date -s 00:01:01
Mon May 5 00:01:01 CST 2014
[root@CactiEZ ~]# php -r 'echo date("h");'
12[root@CactiEZ ~]#
related information in php.ini
[Date]
date.timezone = PRC
I follow the source file, and find related code line in function
date_format (ext/date/php_date.c)
static char *date_format(char *format, int format_len, timelib_time *t,
int localtime)
{
...
case 'h': length = slprintf(buffer, 32, "%02d", (t->h % 12) ? (int)
t->h % 12 : 12); break;
...
}
I think this code line shoud be
case 'h': length = slprintf(buffer, 32, "%02d", t->h % 12); break;
Test script:
---------------
php -r 'echo date("h");'
Expected result:
----------------
I think the result should be 00.
Actual result:
--------------
The actual result is 12.
--
Edit bug report at https://bugs.php.net/bug.php?id=67204&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67204&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67204&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67204&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67204&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67204&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67204&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67204&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67204&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67204&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67204&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67204&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67204&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67204&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67204&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67204&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67204&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67204&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67204&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67204&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67204&r=mysqlcfg