Appointments+ conflict with my theme

If you select a time and take a note (say 4pm), then look at the time displayed on the 'confirm appointment' and its 1hr earlier.
After switching the theme to Twenty Sixteen, the issue is gone.

  • Panos

    Hi Steve ,

    What I noticed is that a timestamp would show a one hour difference when using it in date() or date_i18n()

    As an example for timestamp 1530290700 it should be:
    GMT: Friday, June 29, 2018 4:45:00 PM
    as seen here: https://www.epochconverter.com/

    But in your site it returns one hour earlier.

    Since this happens for this specific theme I suspect that somewhere in it there might be called a
    date_default_timezone_set('UTC');
    which could cause this.

    I only managed to meet this in the timthump.php file, but commenting it out doesn't change anything. I might be missing where it gets changed on your site. You can ask theme developer to check this out as he should know better where to look for it.

    As a workaround I have created a mu-plugin file:
    wp-content/mu-plugins/app_confirmation_start_timezone.php
    with the following snippet:

    add_filter( 'app_confirmation_start', function( $start_formated, $start_timestamp ){
    
    	global $appointments;
    	date_default_timezone_set('Europe/London');
    	$start_formated = date($appointments->datetime_format, $start_timestamp);
    	return $start_formated;
    }, 20, 2 );

    This should not affect any other dates on your site as it is called specifically on that action.

    It sets the timezone to London time which coincidentally is the same time as on the time table. Of course you can change that to the correct one. Here you can find a list of supported timezones that you can use: http://php.net/manual/en/timezones.php

    Hope this helps!

    Kind regards!

  • Steve

    Hi,
    thats seems to have worked! Thanks very much. I can now select a timed book the right time...

    ALTHOUGH
    There is something weird still going on and I am not sure if this is anything to do with this issue.

    If I select any of the appointment that appears as the first of the day, say 9am. It produces an error. rather than displaying the confirmation page.

    I have attached an example, but am not sure if this is anything to do with the issue above

  • Predrag Dubajic

    Hi Steve,

    I did some tests with default Twenty Twelve theme and Panos' fix applied but the issue doesn't happen there, so it's quite possible that the issue is still somewhere within the theme itself.

    Could you try with default theme on your installation so we can see if that's indeed the case?

    Also, did you check with theme developers about the changes made and what could be affecting timezones, and why?

    Best regards,
    Predrag

  • Panos

    Hi Steve ,

    I tried to install the theme but it has links to live site built in and the pages I crate are blank so I can't test the shortcodes on my local site.

    I could suggest some quick change for you to do in the file I mentioned above. First comment out the original snippet in the file (wrap it in /* ..... */). Then paste the following somewhere after the closing comment:

    add_action( 'appointments_init', function(){
        date_default_timezone_set('Europe/London');
    }, 1 );

    This should set that timezone for all Appointments tasks. However this might have impact at other places, so if you decide to try this you need to check if it affected any other part of the site.

    Hope this helps!

    Kind regards!

  • Predrag Dubajic

    Hi Steve,

    I was doing some tests with Panos trying to debug this further but I'm afraid that your theme has too many customizations to be tested properly.
    It seems it has been specifically designed to work with your site and it can't be used on other sites out of the box.
    Due to this we couldn't investigate this further from our end and since this is clearly related to your theme, your theme developer will need to check their code and see what's causing the issue.

    Once you get some meaningful information from theme developer do let us know if we can assist any further.

    Best regards,
    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.