• Resolved albusaidys

    (@albusaidys)


    Hello guys!
    So I just installed the plug and I have the calendar on https://www.goolgetours.com/lsbt/contacts/appointments/

    My time is UTC -6 (or American CST). But when I tried to schedule (tried both mobile and regular short code) I get timezone error
    Regards
    Samir

    ------paste of the error is listed below-----
    Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/lsbt/public_html/lsbt/wp-content/plugins/appointment-calendar/calendar/calendar_form.php on line 132
    
    Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/lsbt/public_html/lsbt/wp-content/plugins/appointment-calendar/calendar/calendar_form.php on line 134

    [ Moderator note: 100 identical error messages deleted. ]

Viewing 7 replies - 1 through 7 (of 7 total)
  • abhishek

    (@abhipathak)

    Hi

    plz follow this url https://stackoverflow.com/questions/16765158/date-it-is-not-safe-to-rely-on-the-systems-timezone-settings

    you can do also this

    In /wp/wp-includes/functions.php

    Add the following before the first function:

    date_default_timezone_set(‘UTC’);

    set your time zine in function

    Thanks
    Abhishek

    Thread Starter albusaidys

    (@albusaidys)

    Thank you for your timely response.
    I tried following the link you gave, but most stuff was not applicable.

    I tried inserting code in functions.php, but did not get response… I’m pasting first few portions of the functions.php, where do you think I should put my time code?

    —————-pasted content———–

    [ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

    <?php
    /**
     * Main WordPress API
     *
     * @package WordPress
     */
    
    require( ABSPATH . WPINC . '/option.php' );
    
    /**
     * Convert given date string into a different format.
     *
     * $format should be either a PHP date format string, e.g. 'U' for a Unix
     * timestamp, or 'G' for a Unix timestamp assuming that $date is GMT.
     *
     * If $translate is true then the given date and format string will
     * be passed to date_i18n() for translation.
     *
     * @since 0.71
     *
     * @param string $format    Format of the date to return.
     * @param string $date      Date string to convert.
     * @param bool   $translate Whether the return date should be translated. Default true.
     * @return string|int|bool Formatted date string or Unix timestamp. False if $date is empty.
     */
    function mysql2date( $format, $date, $translate = true ) {
    	if ( empty( $date ) )
    		return false;
    
    	if ( 'G' == $format )
    		return strtotime( $date . ' +0000' );
    
    	$i = strtotime( $date );
    
    	if ( 'U' == $format )
    		return $i;
    
    	if ( $translate )
    		return date_i18n( $format, $i );
    	else
    		return date( $format, $i );
    }
    
    /**
     * Retrieve the current time based on specified type.
     *
     * The 'mysql' type will return the time in the format for MySQL DATETIME field.
     * The 'timestamp' type will return the current timestamp.
     * Other strings will be interpreted as PHP date formats (e.g. 'Y-m-d').
     *
     * If $gmt is set to either '1' or 'true', then both types will use GMT time.
     * if $gmt is false, the output is adjusted with the GMT offset in the WordPress option.
     *
     * @since 1.0.0
     *
     * @param string   $type Type of time to retrieve. Accepts 'mysql', 'timestamp', or PHP date
     *                       format string (e.g. 'Y-m-d').
     * @param int|bool $gmt  Optional. Whether to use GMT timezone. Default false.
     * @return int|string Integer if $type is 'timestamp', string otherwise.
     */
    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 ) ? date( $type ) : date( $type, time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
    	}
    }
    
    /**
     * Retrieve the date in localized format, based on timestamp.
     *
     * If the locale specifies the locale month and weekday, then the locale will
     * take over the format for the date. If it isn't, then the date format string
     * will be used instead.
     *
     * @since 0.71
     *
     * @global WP_Locale $wp_locale
     *
     * @param string   $dateformatstring Format to display the date.
     * @param bool|int $unixtimestamp    Optional. Unix timestamp. Default false.
     * @param bool     $gmt              Optional. Whether to use GMT timezone. Default false.
     *
     * @return string The date, translated if locale specifies it.
     */
    function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) {
    	global $wp_locale;
    	$i = $unixtimestamp;
    
    	if ( false === $i ) {
    		if ( ! $gmt )
    			$i = current_time( 'timestamp' );
    		else
    			$i = time();
    		// we should not let date() interfere with our
    		// specially computed timestamp
    		$gmt = true;
    	}
    
    	/*
    	 * Store original value for language with untypical grammars.
    	 * See https://core.trac.www.ads-software.com/ticket/9396
    	 */
    	$req_format = $dateformatstring;
    
    	$datefunc = $gmt? 'gmdate' : 'date';
    
    	if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) {
    		$datemonth = $wp_locale->get_month( $datefunc( 'm', $i ) );
    		$datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth );
    		$dateweekday = $wp_locale->get_weekday( $datefunc( 'w', $i ) );
    		$dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday );
    		$datemeridiem = $wp_locale->get_meridiem( $datefunc( 'a', $i ) );
    		$datemeridiem_capital = $wp_locale->get_meridiem( $datefunc( 'A', $i ) );
    		$dateformatstring = ' '.$dateformatstring;
    		$dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring );
    		$dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . backslashit( $datemonth ), $dateformatstring );
    		$dateformatstring = preg_replace( "/([^\\\])l/", "\\1" . backslashit( $dateweekday ), $dateformatstring );
    		$dateformatstring = preg_replace( "/([^\\\])M/", "\\1" . backslashit( $datemonth_abbrev ), $dateformatstring );
    		$dateformatstring = preg_replace( "/([^\\\])a/", "\\1" . backslashit( $datemeridiem ), $dateformatstring );
    		$dateformatstring = preg_replace( "/([^\\\])A/", "\\1" . backslashit( $datemeridiem_capital ), $dateformatstring );
    
    		$dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
    	}
    	$timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' );
    	$timezone_formats_re = implode( '|', $timezone_formats );
    	if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) ) {
    		$timezone_string = get_option( 'timezone_string' );
    		if ( $timezone_string ) {
    			$timezone_object = timezone_open( $timezone_string );
    			$date_object = date_create( null, $timezone_object );
    			foreach( $timezone_formats as $timezone_format ) {
    				if ( false !== strpos( $dateformatstring, $timezone_format ) ) {
    					$formatted = date_format( $date_object, $timezone_format );
    					$dateformatstring = ' '.$dateformatstring;
    					$dateformatstring = preg_replace( "/([^\\\])$timezone_format/", "\\1" . backslashit( $formatted ), $dateformatstring );
    					$dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
    				}
    			}
    		}
    	}
    	$j = @$datefunc( $dateformatstring, $i );
    
    	/**
    	 * Filter the date formatted based on the locale.
    	 *
    	 * @since 2.8.0
    	 *
    	 * @param string $j          Formatted date string.
    	 * @param string $req_format Format to display the date.
    	 * @param int    $i          Unix timestamp.
    	 * @param bool   $gmt        Whether to convert to GMT for time. Default false.
    	 */
    	$j = apply_filters( 'date_i18n', $j, $req_format, $i, $gmt );
    	return $j;
    }

    Hi ,

    you can put your timezone in index.php in line number 15

    date_default_timezone_set(‘Africa/Lagos’);//or change to whatever timezone you want

    Thanks
    Abhihsek

    Thread Starter albusaidys

    (@albusaidys)

    Tried it, it still did not work
    Here is my index.php NOW

    [ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

    <?php
    /**1
     * Front to the WordPress application. This file doesn't do anything, but loads
     * wp-blog-header.php which does and tells WordPress to load the theme.
     *
     * @package WordPress
     */
    
    /**
     * Tells WordPress to load the WordPress theme and output it.
     *
     * @var bool
     */
    define('WP_USE_THEMES', true);
    
    date_default_timezone_set('America/Chicago');
    
    /** Loads the WordPress Environment and Template */
    require( dirname( __FILE__ ) . '/wp-blog-header.php' );
    Thread Starter albusaidys

    (@albusaidys)

    Today I installed about 15 calendar plug-ins and un-installed them, because none of them came close to what your plug-in could do for me.
    I was able to schedule, with other plug-ins, it even said that my time zone was set to GMT-6 etc. So I think as far as setting the time, that part is fixed, we don’t have to worry. Now I am just waiting for your results. I would not mind paying for the paid one… however I’m afraid, if this one does not work, will the paid one work?

    Thanks
    Samir

    Hi albusaidys,

    undo all above change and try this

    go to in your plugin directory >> calendar >> calendar_form.php

    open calendar_form.php and on line number 2 set your default time zone

    date_default_timezone_set(‘America/Los_Angeles’);

    let me know did it work

    Thanks
    Abhishek

    Thread Starter albusaidys

    (@albusaidys)

    IT WORKED!
    Thank you so much.
    I will contact you soon about upgrading to premium version.
    I want people to be able to pay on line to reserve a time slot.
    I hope I won’t have to go through all this.
    Thank you so much Abhishek
    You’re the man!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Unable to schedule, timezone setting error!’ is closed to new replies.