• Resolved Guido

    (@guido07111975)


    Hi again,

    After hours of trying another issue.

    I’m building a date format switch using this tutorial.

    I have changed the converter to change the php-dateformat into js-dateformat:

    // set datepicker date formats for europe and us
    function datepicker_dateformat($output) {
    	if ($output == 'j F Y' || $output == 'd/m/Y') {
    		$output = 'dd-mm-yy';
    	} else {
    		$output = 'yy-mm-dd';
    	}
    	return $output;
    }

    Question, how do I retrieve the $output for use as dateformat in the value of my date input field?

    value="<?php echo date_i18n( get_option( 'date_format' ), esc_attr( $event_date ) ); ?>"

    I know I have to replace the date_format part, but what should I add here?

    Guido

Viewing 1 replies (of 1 total)
  • Thread Starter Guido

    (@guido07111975)

    Yes, did found it myself.

    Don’t use the function for this.
    Create this to set the same dateformat for value:

    // set datepicker date formats for europe and us
    $output = get_option( 'date_format' );
    if ($output == 'j F Y' || $output == 'd/m/Y') {
    	$output = 'd-m-Y';
    } else {
    	$output = 'Y-m-d';
    }
    
    // the date input field value
    value="<?php echo date_i18n( $output , esc_attr( $event_date ) ); ?>"

    Resolved ??

    Guido

Viewing 1 replies (of 1 total)
  • The topic ‘Use dateformat outside the function’ is closed to new replies.