summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);