Pergunta sobre WP Datepicker do WordPress: Datepicker está excedendo valores errados

Um usuário perguntou ?

Olá,

O datepicker está aparecendo quando pressiono o campo de entrada, mas está executando valores errados. Eu quero exibir algum texto depois que o usuário seleciona uma data no datepicker.

Aqui está o meu código:

<?php /* Template Name: calendar */ ?>
<?php wp_enqueue_script("jquery"); ?>
<script src="
<script src="
<link href=" rel="stylesheet" />
<link href=" rel="stylesheet" />

<link href=" />

<?php

get_header();
?>

  <section id="primary" class="content-area">
    <main id="main" class="site-main">

<script>
$.noConflict();
jQuery(document).ready(function($) 	{

  $('#app_fill').datepicker({
    dateFormat: "dd/mm/yy"
  });

  $('#app_reg').datepicker({
    dateFormat: "dd/mm/yy"
  });
});
</script>

</head>
<body>
<form action="calendar.php" method="post" autocomplete="off">
<div class="form-group">
  <label>When was the application filed?</label>
  <div class="input-group date" id='datetimepicker1'>
    <input type="text" class="form-control" name="app_fill" name="app_fill" id="app_fill" required />
    <span class="input-group-addon">
      <span class="glyphicon glyphicon-calendar"></span>
    </span>
  </div>
</div>

<div class="form-group">
  <label>Is the mark registered?</label>
  <select id="mark" name="mark" class="form-control" required>
  <option value="yes">Yes</option>
  <option value="no">No</option>
</select>
</div>

<div class="form-group">
  <label>If yes, when was it registered?</label>
  <div class="input-group date" id='datetimepicker2'>
    <input type="text" class="form-control" name="app_reg" id="app_reg" required/>
    <span class="input-group-addon">
      <span class="glyphicon glyphicon-calendar"></span>
    </span>
  </div>
</form>

<input type="submit" name="submit" value="submit">
</div>
<div class="text">
	
</div>

<?php
//if mark is not registered
    if(isset($_POST['app_fill']) && ($_POST['mark'] == 'no')) {

//-------------------------application date-----------------------------//
       //add 3 years
      $date_app_fill = $_POST['app_fill'];
      $date_app_fill=date("d/m/Y", strtotime($date_app_fill));
      $input1 = new DateTime($date_app_fill);
      $input1->add(new DateInterval('P3Y'));
      $three_y=$input1->format('j F Y');
        
      //add 3 years 6 months
      $date_app_fill_1 = $_POST['app_fill'];
      $input2 = new DateTime(date("d/m/Y", strtotime($date_app_fill_1)));
      $input2->add(new DateInterval('P3Y6M'));
      $three_y_six_m=$input2->format('j F Y');
  
      //output text
      echo "
 		The declaration of actual use or non-use of the mark should be filed not later than ".$three_y." but a six-month extension until ".$three_y_six_m."   may be requested. The extension requested should be filed not later than ".$three_y.".
 			";
	}

  //if mark is registered
	if(isset($_POST['app_fill']) && ($_POST['mark'] != 'no')){

//-------------------------application date-----------------------------//
      //add 3 years
      $date_app_fill = $_POST['app_fill'];
      $date_app_fill=date("d/m/Y", strtotime($date_app_fill));
      $input1 = new DateTime($date_app_fill);
      $input1->add(new DateInterval('P3Y'));
      $three_y=$input1->format('j F Y');
        
      //add 3 years 6 months
      $date_app_fill_1 = $_POST['app_fill'];
      $input2 = new DateTime(date("d/m/Y", strtotime($date_app_fill_1)));
      $input2->add(new DateInterval('P3Y6M'));
      $three_y_six_m=$input2->format('j F Y');

//-------------------------register date-----------------------------//
      //add 5 years 0 months 1 day
      $date_app_reg = $_POST['app_reg'];
      $input3 = new DateTime(date("d/m/Y", strtotime($date_app_reg)));
      $input3->add(new DateInterval('P5Y1D'));
      $five_y_one_d=$input3->format('j F Y');

      //add 6 years 
      $date_app_reg_1 = $_POST['app_reg'];
      $input4 = new DateTime(date("d/m/Y", strtotime($date_app_reg_1)));
      $input4->add(new DateInterval('P6Y'));
      $six_y=$input4->format('j F Y');

      //add 10 years
      $date_app_reg_2 = $_POST['app_reg'];
      $input5 = new DateTime(date("d/m/Y", strtotime($date_app_reg_2)));
      $input5->add(new DateInterval('P10Y'));
      $ten_y=$input5->format('j F Y');

      //add 10 years minus 6 months
      $date_app_reg_3 = $_POST['app_reg'];
      $input6 = new DateTime(date("d/m/Y", strtotime($date_app_reg_3)));
      $input6->add(new DateInterval('P9Y6M'));
      $nine_y_six_m=$input6->format('j F Y');

      //add 10 years 6 months
      $date_app_reg_4 = $_POST['app_reg'];
      $input7 = new DateTime(date("d/m/Y", strtotime($date_app_reg_4)));
      $input7->add(new DateInterval('P10Y6M'));
      $ten_y_six_m=$input7->format('j F Y');

      //add 11 years
      $date_app_reg_5 = $_POST['app_reg'];
      $input8 = new DateTime(date("d/m/Y", strtotime($date_app_reg_5)));
      $input8->add(new DateInterval('P11Y'));
      $eleven_y=$input8->format('j F Y');

      //output text
      echo "
 		The declaration of actual use or non-use of the mark should be filed not later than ".$three_y." but a six-month extension until ".$three_y_six_m." may be requested. The extension requested should be filed not later than ".$three_y.".
<br>
A declaration should again be filed within one year from the 5th anniversary of the registration of the mark, or from ".$five_y_one_d." until ".$six_y.".
<br>
The registration is due for renewal by ".$ten_y.". The renewal application may be filed from ".$nine_y_six_m." until ".$ten_y.". After ".$ten_y.", the renewal application may still be filed not later than ".$ten_y_six_m.".
<br>
A declaration should then be filed within one year from the renewal of the registration of the mark, or until ".$eleven_y.", without possibility of extension.
 			";
	}
?>

<?php
get_footer();

Isto é o que eu coloquei nas configurações do datepicker: #app_fill, #app_reg

Agradeceríamos qualquer ajuda!

(@gpthemes)

1 ano, 3 meses atrás

Desculpe, você está tentando fazer de outra maneira. Você não está usando este plugin. Este plugin apenas converte um tipo de postagem normal em um campo de calendário.

lançador de tópicos

(@coolwen22)

1 ano, 3 meses atrás

Oi, então o que eu preciso fazer para obter este campo de calendário calculado e exibido?

(@gpthemes)

1 ano, 3 meses atrás

tente o próximo tópico

lançador de tópicos

(@coolwen22)

1 ano, 3 meses atrás

Ele primeiro mostra o valor correto, mas quando eu retorno a página e tento novamente, ele passa um valor em branco (mostra 1970).

(@gpthemes)

1 ano, 3 meses atrás

Você pode ter mais de um campo e o outro campo fornece o valor padrão. 1970 é o valor de timestamp padrão e incorreto no PHP.

(@fahadmahmood)

1 ano, 1 mês atrás

@coolwen22 você já resolveu esse problema? Obrigado @gpthemes

Isto foi útil?

0 / 0

Deixe um comentário 0

Your email address will not be published. Required fields are marked *