Skip to content

Commit f8fdee1

Browse files
committed
Fix for bug php#1750.
1 parent 07e3010 commit f8fdee1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ext/standard/datetime.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
197197
case 'j': /* day of the month, numeric, no leading zeros */
198198
case 'H': /* hour, numeric, 24 hour format */
199199
case 'h': /* hour, numeric, 12 hour format */
200+
case 'G': /* hour, numeric, 24 hour format, no leading zeroes */
201+
case 'g': /* hour, numeric, 12 hour format, no leading zeroes */
200202
case 'i': /* minutes, numeric */
201203
case 's': /* seconds, numeric */
202204
case 'A': /* AM/PM */
@@ -278,6 +280,15 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
278280
sprintf(tmp_buff, "%02d", h); /* SAFE */
279281
strcat(return_value->value.str.val, tmp_buff);
280282
break;
283+
case 'G': /* hour, numeric, 24 hour format, no leading zeros */
284+
sprintf(tmp_buff, "%d", ta->tm_hour); /* SAFE */
285+
strcat(return_value->value.str.val, tmp_buff);
286+
break;
287+
case 'g': /* hour, numeric, 12 hour format, no leading zeros */
288+
h = ta->tm_hour % 12; if (h==0) h = 12;
289+
sprintf(tmp_buff, "%d", h); /* SAFE */
290+
strcat(return_value->value.str.val, tmp_buff);
291+
break;
281292
case 'i': /* minutes, numeric */
282293
sprintf(tmp_buff, "%02d", ta->tm_min); /* SAFE */
283294
strcat(return_value->value.str.val, tmp_buff);

0 commit comments

Comments
 (0)