From: Andrey Hristov Date: Tue, 20 Jul 1999 19:11:32 +0000 (+0000) Subject: Added 'n' option to date(). X-Git-Tag: php-4.0b1~42 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3ff606a9341143c2e8fc05d4a64a86fbcaa97b16;p=php Added 'n' option to date(). --- diff --git a/ChangeLog.TODO b/ChangeLog.TODO index 864375cb54..413b1ff765 100644 --- a/ChangeLog.TODO +++ b/ChangeLog.TODO @@ -15,10 +15,6 @@ over to PHP4. - PUT method support (mlemos@acm.org) - Fix parameter count problem in odbc_setoption() - Really fix implode() this time. The fix in 3.0.7 was bogus -- Added more option to the date() function: (Colin Viebrock) - 'g' - hour, 12-hour format, no leading zeros - 'G' - hour, 24-hour format, no leading zeros - 'n' - month, numeric, no leading zeros - Make fgetss() slightly smarter - Add strip_tags() which uses the fgetss state-machine but acts on a string diff --git a/ext/standard/datetime.c b/ext/standard/datetime.c index 4b19f459e9..41f6765362 100644 --- a/ext/standard/datetime.c +++ b/ext/standard/datetime.c @@ -193,6 +193,7 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm) break; case 'y': /* year, numeric, 2 digits */ case 'm': /* month, numeric */ + case 'n': /* month, numeric, no leading zeroes */ case 'd': /* day of the month, numeric */ case 'j': /* day of the month, numeric, no leading zeros */ case 'H': /* hour, numeric, 24 hour format */ @@ -263,6 +264,10 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm) sprintf(tmp_buff, "%02d", ta->tm_mon + 1); /* SAFE */ strcat(return_value->value.str.val, tmp_buff); break; + case 'n': /* month, numeric, no leading zeros */ + sprintf(tmp_buff, "%d", ta->tm_mon + 1); /* SAFE */ + strcat(return_value->value.str.val, tmp_buff); + break; case 'd': /* day of the month, numeric */ sprintf(tmp_buff, "%02d", ta->tm_mday); /* SAFE */ strcat(return_value->value.str.val, tmp_buff);