File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 1
1
PHP NEWS
2
2
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3
3
?? ??? 2004, PHP 5.1.0
4
+ - Allow gettimeofday() return a float if optional argument is specified. (Ilia)
4
5
- Added sqlite_fetch_column_types() 3rd argument for arrays. (Ilia)
5
6
- Added optional offset parameter to stream_get_contents() and
6
7
file_get_contents(). (Ilia)
Original file line number Diff line number Diff line change @@ -88,12 +88,22 @@ PHP_FUNCTION(microtime)
88
88
#ifdef HAVE_GETTIMEOFDAY
89
89
PHP_FUNCTION (gettimeofday )
90
90
{
91
+ zend_bool get_as_float = 0 ;
92
+
93
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "|b" , & get_as_float ) == FAILURE ) {
94
+ return ;
95
+ }
96
+
91
97
struct timeval tp ;
92
98
struct timezone tz ;
93
99
94
100
memset (& tp , 0 , sizeof (tp ));
95
101
memset (& tz , 0 , sizeof (tz ));
96
102
if (gettimeofday (& tp , & tz ) == 0 ) {
103
+ if (get_as_float ) {
104
+ RETURN_DOUBLE ((double )(tp .tv_sec + tp .tv_usec / MICRO_IN_SEC ));
105
+ }
106
+
97
107
array_init (return_value );
98
108
add_assoc_long (return_value , "sec" , tp .tv_sec );
99
109
add_assoc_long (return_value , "usec" , tp .tv_usec );
You can’t perform that action at this time.
0 commit comments