So, have a plugin that's a bit busted, it's meant to do a count down till next days opening hour. It seems to be adding on an additional 1.5 hours, i've tried a few things and nothing seem to to have an effect on it.
Original Code:
// JS counters data
$right_now = current_time( 'Y-m-j' );
$time_now = current_time( 'timestamp' );
$tomorrow_time = date( 'Y-m-j', strtotime('+1 day', $time_now ) );
if ( $opening_time < $closing_time ) {
$to_time = $right_now . ' ' . $closing_time;
$from_time = $tomorrow_time . ' ' . $opening_time;
} else {
$to_time = $right_now . ' ' . $closing_time;
$from_time = $right_now . ' ' . $opening_time;
}
I've tried this:
// JS counters data
$right_now = current_time( 'Y-m-j' );
$time_now = current_time( 'timestamp' );
$hours_fix = current_time( 'timestamp', strtotime('-1 hours, -30 minutes') );
$tomorrow_time = date( 'Y-m-j', strtotime('+1 day', $hours_fix ) );
if ( $opening_time < $closing_time ) {
$to_time = $right_now . ' ' . $closing_time;
$from_time = $tomorrow_time . ' ' . $opening_time;
} else {
$to_time = $right_now . ' ' . $closing_time;
$from_time = $right_now . ' ' . $opening_time;
}
And a few other bits similar to adding an additional line to cover the 1.5 hours also tried changing the +1 day to +22 hours but the time doesn't move it's still 1.5 hours a head of what it should be, (i can't see any fixed timezone settings in the code so it should be pulling the time from the Wordpress install which is the correct time! Any one got any points here?
strtotime
intocurrent_time
as a second parameter, which is confusing because the second parameter of that function is a true/false value according to the official documentation. Can you explain the reasoning behind this and what you hoped it would do?