Some common js and php tricks
👉Convert timestamp into date formate like 25 january 2021 in php   (suppose this is the orignal date     fetched from database $row['create_date'] )
📌echo date('d F Y', strtotime($row['create_date']));  
👉For filter From  date - To date required script for validation like To date can not be smaller then From date 
📌input box for From  date  <input name="fdate" id="fdate" class="form-control">
input box for From  date       <input  name="tdate" id="tdate" class="form-control">
javascript : 
<script type="text/javascript">
   	$("#tdate").datepicker({
 dateFormat : 'yy-mm-dd',
 });
$("#fdate").datepicker({
 dateFormat : 'yy-mm-dd',
  onSelect: function(date) {
    $("#tdate").datepicker('option', 'minDate', date);
  }
});
$("#tdate").datepicker({});
   </script>
Note : You need to have datepicker jquery and ui 
👉Show hide a div on check of a input field 
#ebook is id of that input box . #ebook_link is the id of the div which you want to show hide.
 showhidebox();
      function showhidebox()
      {
          if($('#ebook').is(":checked"))
          {
              $('#ebook_link').show();
          }
          else
          {
              $('#ebook_link').hide();
          }
          return true;
      }
👉Disabke dates before 04/22/2021 and after 04/22/2022  in datepicker
sol:- we can do this by jqueary
 $(function() {
    $( "#startdate" ).datepicker({
      changeMonth: true,  
      changeYear:true,      
      minDate:'04/22/2021',
      onSelect: function( selectedDate ) {
        $( "#to" ).datepicker( "option", "minDate", selectedDate );
      }
    });
    $( "#enddate" ).datepicker({
      changeMonth: true,  
      changeYear:true,      
      maxDate:' 04/22/2022 ',
      onSelect: function( selectedDate ) {
        $( "#to" ).datepicker( "option", "minDate", selectedDate );
      }
    });
  });

0 Comments