Posts

PHP: Calculate duration between two dates

<?php $date11 = '2013-03-12'; $date22 = '2013-03-15'; $date11 = strtotime($date11); $date22 = strtotime($date22); $diff = $date22 - $date11; $diff_in_days = floor($diff/(60*60*24)); echo $diff_in_days; // 3 ?> <?php $date11 = '2013-03-15'; $date22 = '2013-03-12'; $date11 = strtotime($date11); $date22 = strtotime($date22); $diff = $date22 - $date11; $diff_in_days = floor($diff/(60*60*24)); echo $diff_in_days; // -3 ?>

jQuery: How to close a dropdown on clicking anywhere on the body?

jQuery: How to close a dropdown on clicking anywhere on the body? The dropdown is displayed when user click on the 'more' button, to hide the dropdown again user should click on the 'more' button again. But if user want to close the dropdown by clicking anywhere on the body so we need add code on click document. HTML ----- <a class="select-link" href="https://www.blogger.com/blogger.g?blogID=3817399277949715318#"><a href="#" class="select-link">Select List</a> <ul class="dropdown-menu-list"> <li><a href="#">My item name 1</a></li> <li><a href="#">My item name 2</a></li> <li><a href="#">My item name 3</a></li> <li><a href="#">My item name 4</a></li> </ul> CSS --- .dropdown-menu-list {display:none;} jQuery --- $(".select-link")...

MySql: Fixed sort datetime string field dd-mm-yyyy

If you using a system where the dates are stored as strings in the format dd/mm/yyyy or dd-mm-yyyy. Is it possible to convert this to yyyy-mm-dd in a sort Query. Table:Product year ---- 20-08-2015 02-03-2010 03-03-2011 02-03-2011 02-04-2011 SELECT `year` FROM `Product` WHERE 1 order BY DATE_FORMAT(STR_TO_DATE(`year`, '%d-%m-%Y'), '%Y-%m-%d') DESC

PHP: Date Difference for PHP 5.2

function days_diff($d1, $d2) {     $x1 = days($d1);     $x2 = days($d2);      if ($x1 && $x2) {         return abs($x1 - $x2);     } } function days($x) {     if (get_class($x) != 'DateTime') {         return false;     }      $y = $x->format('Y') - 1;     $days = $y * 365;     $z = (int)($y / 4);     $days += $z;     $z = (int)($y / 100);     $days -= $z;     $z = (int)($y / 400);     $days += $z;     $days += $x->format('z');     return $days; } // Call function $start_date = '2015-08-19 15:18:19'; $end_date = '2015-08-22 15:18:19'; $date1=date_create(date('Y-m-j',strtotime($start_date))); $date2=date_create(date('Y-m-j',strtotime($end_date))); $diff=date_diff($date1,$date2); echo $diff;

List of svg support in email template

Image
For more details

Bootstrap 3: Equal Height Columns with jQuery

When you want height of each have the same height using coloumn of Bootstrap my recommend you should Javascript calculate height of each row if you using css maybe not support all browser. 1. Html Code <div class="row eq-heights">       <div class="eq-col-sm-4 eq-col-md-4 col-md-4">       <div class="content clearfix">column 1 first in source </div>        </div>     <div class="eq-col-sm-4 eq-col-md-4 col-md-4">         <div class="content clearfix">col 2 second in source </div>        </div>     <div class="eq-col-sm-4 eq-col-md-4 col-md-4">         <div class="content clearfix"> Third in source. something fdaf fafdafd  dafdafdafdaf fdafdf ffdfdfd something fdaf fafdafd  dafdafdafdaf fdafdf ffdfdfd something fdaf...

jQuery to hide a DIV when the user clicks outside of container

- Html code <a href="#" class="select-link">Select List</a> <ul class="dropdown-menu-list">     <li><a href="#">My item name 1</a></li>     <li><a href="#">My item name 2</a></li>     <li><a href="#">My item name 3</a></li>     <li><a href="#">My item name 4</a></li> </ul> - Css Code .dropdown-menu-list {display:none;} - jQuery Code $(".select-link").on('click',function(e) {     e.preventDefault();     $(".dropdown-menu-list").show(); }) $(document).mouseup(function (e) {     var container = $("YOUR CONTAINER SELECTOR");     if (!container.is(e.target) // if the target of the click isn't the container...         && container.has(e.target).length === 0) // ... nor a descendant of the contain...