summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>1999-07-20 16:59:30 +0000
committerAndrey Hristov <andrey@php.net>1999-07-20 16:59:30 +0000
commitf8fdee1c66db32db3af4a3af321938d59a69ef4f (patch)
tree996b8b24896df33b6add8e88a10b8d43ed58fba0
parent07e30106b9c3bfd8d451be5a4403cb7d3fc2fcd8 (diff)
downloadphp-git-f8fdee1c66db32db3af4a3af321938d59a69ef4f.tar.gz
Fix for bug #1750.
-rw-r--r--ext/standard/datetime.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/ext/standard/datetime.c b/ext/standard/datetime.c
index 9be3bc80ae..4b19f459e9 100644
--- a/ext/standard/datetime.c
+++ b/ext/standard/datetime.c
@@ -197,6 +197,8 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
case 'j': /* day of the month, numeric, no leading zeros */
case 'H': /* hour, numeric, 24 hour format */
case 'h': /* hour, numeric, 12 hour format */
+ case 'G': /* hour, numeric, 24 hour format, no leading zeroes */
+ case 'g': /* hour, numeric, 12 hour format, no leading zeroes */
case 'i': /* minutes, numeric */
case 's': /* seconds, numeric */
case 'A': /* AM/PM */
@@ -278,6 +280,15 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
sprintf(tmp_buff, "%02d", h); /* SAFE */
strcat(return_value->value.str.val, tmp_buff);
break;
+ case 'G': /* hour, numeric, 24 hour format, no leading zeros */
+ sprintf(tmp_buff, "%d", ta->tm_hour); /* SAFE */
+ strcat(return_value->value.str.val, tmp_buff);
+ break;
+ case 'g': /* hour, numeric, 12 hour format, no leading zeros */
+ h = ta->tm_hour % 12; if (h==0) h = 12;
+ sprintf(tmp_buff, "%d", h); /* SAFE */
+ strcat(return_value->value.str.val, tmp_buff);
+ break;
case 'i': /* minutes, numeric */
sprintf(tmp_buff, "%02d", ta->tm_min); /* SAFE */
strcat(return_value->value.str.val, tmp_buff);