diff --git a/NEWS b/NEWS index 906b9c1fa5c4d..933740df55680 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,9 @@ PHP NEWS - FPM: . Emit error for invalid port setting. (David Carlier) +- Date: + . idate() now accepts format specifiers "N" and "o" + - Intl: . Update all grandfathered language tags with preferred values . Fixed GH-7939 (Cannot unserialize IntlTimeZone objects). (cmb) diff --git a/UPGRADING b/UPGRADING index 2d76009808b07..86521c648b78f 100644 --- a/UPGRADING +++ b/UPGRADING @@ -40,6 +40,9 @@ PHP 8.2 UPGRADE NOTES . Added CURLINFO_EFFECTIVE_METHOD option and returning the effective HTTP method in curl_getinfo() return value. +- Date: + . idate() now accepts format specifiers "N" and "o". + - OCI8: . Added an oci8.prefetch_lob_size directive and oci_set_prefetch_lob() function to tune LOB query performance by reducing the number of diff --git a/ext/date/php_date.c b/ext/date/php_date.c index e51dcbe760504..cae1b8d343540 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -882,6 +882,7 @@ PHPAPI int php_idate(char format, time_t ts, bool localtime) /* day */ case 'd': case 'j': retval = (int) t->d; break; + case 'N': retval = (int) timelib_iso_day_of_week(t->y, t->m, t->d); break; case 'w': retval = (int) timelib_day_of_week(t->y, t->m, t->d); break; case 'z': retval = (int) timelib_day_of_year(t->y, t->m, t->d); break; @@ -896,6 +897,7 @@ PHPAPI int php_idate(char format, time_t ts, bool localtime) case 'L': retval = (int) timelib_is_leap((int) t->y); break; case 'y': retval = (int) (t->y % 100); break; case 'Y': retval = (int) t->y; break; + case 'o': retval = (int) isoyear; break; /* iso year */ /* Swatch Beat a.k.a. Internet Time */ case 'B': diff --git a/ext/standard/tests/time/idate.phpt b/ext/standard/tests/time/idate.phpt index 1a06070b45e3c..dc006f7acf465 100644 --- a/ext/standard/tests/time/idate.phpt +++ b/ext/standard/tests/time/idate.phpt @@ -3,7 +3,7 @@ idate() function --FILE-- +--EXPECT-- +U: 1041808859 +w: 0 +N: 7 +W: 1 +U: 1072912859 +Y: 2003 +o: 2004 +W: 1