Skip to content
11 changes: 10 additions & 1 deletion ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,10 @@ PHP_RSHUTDOWN_FUNCTION(date)

#define DATE_FORMAT_ISO8601 "Y-m-d\\TH:i:sO"

#define DATE_FORMAT_SQL "Y-m-d"

#define DATE_FORMAT_SQLTIMESTAMP "Y-m-d H:i:s"

#define DATE_TZ_ERRMSG \
"It is not safe to rely on the system's timezone settings. You are " \
"*required* to use the date.timezone setting or the " \
Expand Down Expand Up @@ -842,6 +846,9 @@ PHP_MINIT_FUNCTION(date)
*/
REGISTER_STRING_CONSTANT("DATE_RSS", DATE_FORMAT_RFC1123, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("DATE_W3C", DATE_FORMAT_RFC3339, CONST_CS | CONST_PERSISTENT);

REGISTER_STRING_CONSTANT("DATE_SQL", DATE_FORMAT_SQL, CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT("DATE_SQLTIMESTAMP", DATE_FORMAT_SQLTIMESTAMP, CONST_CS | CONST_PERSISTENT);

REGISTER_LONG_CONSTANT("SUNFUNCS_RET_TIMESTAMP", SUNFUNCS_RET_TIMESTAMP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SUNFUNCS_RET_STRING", SUNFUNCS_RET_STRING, CONST_CS | CONST_PERSISTENT);
Expand Down Expand Up @@ -2011,7 +2018,9 @@ static void date_register_classes(TSRMLS_D)
REGISTER_DATE_CLASS_CONST_STRING("RFC3339", DATE_FORMAT_RFC3339);
REGISTER_DATE_CLASS_CONST_STRING("RSS", DATE_FORMAT_RFC1123);
REGISTER_DATE_CLASS_CONST_STRING("W3C", DATE_FORMAT_RFC3339);

REGISTER_DATE_CLASS_CONST_STRING("SQL", DATE_FORMAT_SQL);
REGISTER_DATE_CLASS_CONST_STRING("SQLTIMESTAMP", DATE_FORMAT_SQLTIMESTAMP);

INIT_CLASS_ENTRY(ce_immutable, "DateTimeImmutable", date_funcs_immutable);
ce_immutable.create_object = date_object_new_date;
date_ce_immutable = zend_register_internal_class_ex(&ce_immutable, NULL, NULL TSRMLS_CC);
Expand Down
6 changes: 5 additions & 1 deletion ext/date/tests/DateTime_format_basic2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ var_dump( $date->format( DateTime::RFC822) ) ;
var_dump( $date->format( DateTime::RFC850) ) ;
var_dump( $date->format( DateTime::RFC1036) ) ;
var_dump( $date->format( DateTime::RFC1123) ) ;
var_dump( $date->format( DateTime:: RFC2822) ) ;
var_dump( $date->format( DateTime::RFC2822) ) ;
var_dump( $date->format( DateTime::RFC3339) ) ;
var_dump( $date->format( DateTime::RSS) ) ;
var_dump( $date->format( DateTime::W3C) ) ;
var_dump( $date->format( DateTime::SQL) ) ;
var_dump( $date->format( DateTime::SQLTIMESTAMP) ) ;

?>
===DONE===
Expand All @@ -41,4 +43,6 @@ string(31) "Thu, 14 Jul 2005 22:30:41 +0100"
string(25) "2005-07-14T22:30:41+01:00"
string(31) "Thu, 14 Jul 2005 22:30:41 +0100"
string(25) "2005-07-14T22:30:41+01:00"
string(10) "2005-07-14"
string(19) "2005-07-14 22:30:41"
===DONE===
8 changes: 6 additions & 2 deletions ext/date/tests/DateTime_verify.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ array(18) {
}
}
..and get names of all its class constants
array(11) {
array(13) {
["ATOM"]=>
string(13) "Y-m-d\TH:i:sP"
["COOKIE"]=>
Expand All @@ -179,5 +179,9 @@ array(11) {
string(16) "D, d M Y H:i:s O"
["W3C"]=>
string(13) "Y-m-d\TH:i:sP"
["SQL"]=>
string(5) "Y-m-d"
["SQLTIMESTAMP"]=>
string(11) "Y-m-d H:i:s"
}
===DONE===
===DONE===
14 changes: 12 additions & 2 deletions ext/date/tests/date_constants.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Date constants
DATE_RFC2822,
DATE_RFC3339,
DATE_RSS,
DATE_W3C
DATE_W3C,
DATE_SQL,
DATE_SQLTIMESTAMP
);

foreach($constants as $const) {
Expand All @@ -35,7 +37,9 @@ Date constants
DATE_RFC2822 == DateTime::RFC2822,
DATE_RFC3339 == DateTime::RFC3339,
DATE_RSS == DateTime::RSS,
DATE_W3C == DateTime::W3C
DATE_W3C == DateTime::W3C,
DATE_SQL == DateTime::SQL,
DATE_SQLTIMESTAMP == DateTime::SQLTIMESTAMP
);
?>
--EXPECT--
Expand All @@ -61,6 +65,10 @@ string(31) "Sat, 01 Jul 2006 14:27:30 +0200"
string(31) "Tue, 30 May 2006 14:32:13 +0200"
string(25) "2006-07-01T14:27:30+02:00"
string(25) "2006-05-30T14:32:13+02:00"
string(10) "2006-07-01"
string(10) "2006-05-30"
string(19) "2006-07-01 14:27:30"
string(19) "2006-05-30 14:32:13"

bool(true)
bool(true)
Expand All @@ -73,3 +81,5 @@ bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
4 changes: 3 additions & 1 deletion ext/date/tests/strtotime2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ $constants = array(
'DATE_RFC2822',
'DATE_RFC3339',
'DATE_RSS',
'DATE_W3C'
'DATE_W3C',
'DATE_SQLTIMESTAMP'
);


Expand All @@ -38,3 +39,4 @@ DATE_RFC2822: OK
DATE_RFC3339: OK
DATE_RSS: OK
DATE_W3C: OK
DATE_SQLTIMESTAMP: OK