Bug #67204 [Opn->Nab]: In midnight,date("h") return 12,is it correct?

From: Date: Mon, 05 May 2014 03:38:35 +0000
Subject: Bug #67204 [Opn->Nab]: In midnight,date("h") return 12,is it correct?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185624@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67204&edit=1 ID: 67204 Updated by: requinix@php.net Reported by: zws at ahtvu dot ah dot cn Summary: In midnight,date("h") return 12,is it correct? -Status: Open +Status: Not a bug Type: Bug Package: Date/time related Operating System: Linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: > In midnight,date("h") return 12,is it correct? Yes. There is no hour 0 on the 12-hour clock. Previous Comments: ------------------------------------------------------------------------ [2014-05-05 03:36:12] zws at ahtvu dot ah dot cn 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 this bug report at https://bugs.php.net/bug.php?id=67204&edit=1

« previous php.bugs (#185624) next »