Skip to content

Commit 3ff606a

Browse files
committed
Added 'n' option to date().
1 parent acb9cae commit 3ff606a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

ChangeLog.TODO

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ over to PHP4.
1515
- PUT method support (mlemos@acm.org)
1616
- Fix parameter count problem in odbc_setoption()
1717
- Really fix implode() this time. The fix in 3.0.7 was bogus
18-
- Added more option to the date() function: (Colin Viebrock)
19-
'g' - hour, 12-hour format, no leading zeros
20-
'G' - hour, 24-hour format, no leading zeros
21-
'n' - month, numeric, no leading zeros
2218
- Make fgetss() slightly smarter
2319
- Add strip_tags() which uses the fgetss state-machine but acts on a string
2420

ext/standard/datetime.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
193193
break;
194194
case 'y': /* year, numeric, 2 digits */
195195
case 'm': /* month, numeric */
196+
case 'n': /* month, numeric, no leading zeroes */
196197
case 'd': /* day of the month, numeric */
197198
case 'j': /* day of the month, numeric, no leading zeros */
198199
case 'H': /* hour, numeric, 24 hour format */
@@ -263,6 +264,10 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
263264
sprintf(tmp_buff, "%02d", ta->tm_mon + 1); /* SAFE */
264265
strcat(return_value->value.str.val, tmp_buff);
265266
break;
267+
case 'n': /* month, numeric, no leading zeros */
268+
sprintf(tmp_buff, "%d", ta->tm_mon + 1); /* SAFE */
269+
strcat(return_value->value.str.val, tmp_buff);
270+
break;
266271
case 'd': /* day of the month, numeric */
267272
sprintf(tmp_buff, "%02d", ta->tm_mday); /* SAFE */
268273
strcat(return_value->value.str.val, tmp_buff);

0 commit comments

Comments
 (0)