Pregunta sobre WP Datepicker de Wordpress:

Datepicker está superando valores incorrectos

Un usuario preguntó 👇

Hola,

El selector de fecha se muestra cuando presiono el campo de entrada, pero está ejecutando valores incorrectos. Quiero mostrar algo de texto después de que el usuario seleccione una fecha del selector de fechas.

Aquí está mi código:

<?php /* Template Name: calendar */ ?>
<?php wp_enqueue_script("jquery"); ?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet" />
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/redmond/jquery-ui.css" rel="stylesheet" />

<link href="https://cdnjs.cloudflare.com/ajax/libs/datepicker/0.6.5/datepicker.min.js" />

<?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();

Esto es lo que puse en la configuración del selector de fechas: #app_fill, #app_reg

¡Agradeceríamos cualquier ayuda!

(@gpthemes)

Hace 1 año, 3 meses

Lo siento, estás intentando hacerlo de otra manera. No está utilizando este plugin. Este plugin solo convierte un tipo de entrada normal en un campo de calendario.

Lanzador de hilos

(@ coolwen22)

Hace 1 año, 3 meses

Hola, entonces, ¿qué debo hacer para que este campo de calendario se calcule y se muestre?

(@gpthemes)

Hace 1 año, 3 meses

Prueba el siguiente hilo
https://stackoverflow.com/questions/16373734/jquery-datepicker-restrict-dates-in-second-date-field-based-on-selected-date-in

Lanzador de hilos

(@ coolwen22)

Hace 1 año, 3 meses

Primero muestra el valor correcto, pero cuando devuelvo la página y lo intento de nuevo, pasa un valor en blanco (muestra 1970).

(@gpthemes)

Hace 1 año, 3 meses

Puede tener más de un campo y el otro campo proporciona el valor predeterminado. 1970 es el valor de marca de tiempo predeterminado e incorrecto en PHP.

(@fahadmahmood)

Hace 1 año, 1 mes

@ coolwen22 ¿ya resolvió este problema? Gracias @gpthemes

¿Solucionó tu problema??

0 / 0

Deja una respuesta 0

Tu dirección de correo electrónico no será publicada.