We recently updated our shared hosting to use PHP 7.3 (problem still existed in PHP 7.2 as well) - website is throwing the error in the title.
the function in question is:
function current_time( $type, $gmt = 0 ) {
switch ( $type ) {
case 'mysql':
return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) );
case 'timestamp':
return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
default:
return ( $gmt ) ? gmdate( $type ) : gmdate( $type, time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
}}
Line 68 is:
return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) );
The functions file has not been modified - any ideas what is causing this?
We recently updated our shared hosting to use PHP 7.3 (problem still existed in PHP 7.2 as well) - website is throwing the error in the title.
the function in question is:
function current_time( $type, $gmt = 0 ) {
switch ( $type ) {
case 'mysql':
return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) );
case 'timestamp':
return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
default:
return ( $gmt ) ? gmdate( $type ) : gmdate( $type, time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
}}
Line 68 is:
return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) );
The functions file has not been modified - any ideas what is causing this?
There is another question dealing with a slightly more complicated issue than yours, but it contains a lesson.
Basically, what I learned is that you should process your equation in two or more steps, to account for gmt_offset being returned as a string:
$offset = get_option( 'gmt_offset' );
$hours = (int) $offset;
return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( $hours * HOUR_IN_SECONDS ) ) );
This should avoid the error you are seeing.
Good luck!
HOUR_IN_SECONDS
constant is probably not a numeric.. – Sally CJ Commented Oct 1, 2019 at 20:52