$date2 = '2010-06-20';
$date1 = '2010-06-24';
$days = (strtotime($date1) - strtotime($date2)) / (60 * 60 * 24);
echo $days;
some other ways are also there. can any one reply as a comments
Tuesday, July 27, 2010
Monday, July 26, 2010
Sunday, July 25, 2010
Monday, July 19, 2010
Validate Image Using Javascript
function validate_image()
{
frmobj = document.frmRegistration; //Here "frmRegistration" is Form name
var image_file = frmobj.upload_file.value; /*Here "upload_file" is in this tag like input type="file" name="upload_file" */
var image_length = frmobj.upload_file.value.length;
var pos = image_file.lastIndexOf('.') + 1;
var ext = image_file.substring(pos, image_length);
var final_ext = ext.toLowerCase();
if(final_ext != 'jpg' && final_ext != 'jpeg' && final_ext != 'gif' && final_ext != 'png')
{
alert('Upload valid image');
return false;
}
return true;
}
Usage:
if(!validate_image()) return false;
{
frmobj = document.frmRegistration; //Here "frmRegistration" is Form name
var image_file = frmobj.upload_file.value; /*Here "upload_file" is in this tag like input type="file" name="upload_file" */
var image_length = frmobj.upload_file.value.length;
var pos = image_file.lastIndexOf('.') + 1;
var ext = image_file.substring(pos, image_length);
var final_ext = ext.toLowerCase();
if(final_ext != 'jpg' && final_ext != 'jpeg' && final_ext != 'gif' && final_ext != 'png')
{
alert('Upload valid image');
return false;
}
return true;
}
Usage:
if(!validate_image()) return false;
Sunday, July 18, 2010
create dynamic images in php
//Create Image By Url Method - 2
function create_image_by_url2($url)
{
$path_parts = pathinfo($url);
copy($url,$path_parts['basename']);
}
create_image_by_url2($url);
function create_image_by_url2($url)
{
$path_parts = pathinfo($url);
copy($url,$path_parts['basename']);
}
create_image_by_url2($url);
create dynamic images using php
$url = "http://technmarketing.com/wp-content/uploads/2009/03/twitter-wallpaper2.jpg";
//Create Image By Url Method - 1
function create_image_by_url1($url)
{
$target_path = $url;
$imgdir="";
$path_parts = pathinfo($url);
$file_name = $path_parts['basename'];
$imgext = $path_parts['extension'];
if($imgext=='jpg' || $imgext=='JPG')
$src_img=imagecreatefromjpeg($target_path);
if($imgext=='gif' || $imgext=='GIF')
$src_img=imagecreatefromgif($target_path);
if($imgext=='png' || $imgext=='PNG')
$src_img=imagecreatefrompng($target_path);
if($imgext=='jpeg' || $imgext=='jpeg')
$src_img=imagecreatefromjpeg($target_path);
$size = getimagesize($target_path);
$dst_img = imagecreatetruecolor($size[0],$size[1]);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$size[0],$size[1],$size[0],$size[1]);
if(($imgext=='jpg') || ($imgext=='JPG') || ($imgext=='jpeg') || ($imgext=='JPEG'))
{
imagejpeg($dst_img, $imgdir.$file_name,90);
}else if(($imgext=='gif') || ($imgext=='GIF')){
imagegif($dst_img, $imgdir.$file_name,90);
}else if(($imgext=='png') || ($imgext=='PNG')){
imagepng($dst_img, $imgdir.$file_name,5);
}
}
create_image_by_url1($url);
//Create Image By Url Method - 1
function create_image_by_url1($url)
{
$target_path = $url;
$imgdir="";
$path_parts = pathinfo($url);
$file_name = $path_parts['basename'];
$imgext = $path_parts['extension'];
if($imgext=='jpg' || $imgext=='JPG')
$src_img=imagecreatefromjpeg($target_path);
if($imgext=='gif' || $imgext=='GIF')
$src_img=imagecreatefromgif($target_path);
if($imgext=='png' || $imgext=='PNG')
$src_img=imagecreatefrompng($target_path);
if($imgext=='jpeg' || $imgext=='jpeg')
$src_img=imagecreatefromjpeg($target_path);
$size = getimagesize($target_path);
$dst_img = imagecreatetruecolor($size[0],$size[1]);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$size[0],$size[1],$size[0],$size[1]);
if(($imgext=='jpg') || ($imgext=='JPG') || ($imgext=='jpeg') || ($imgext=='JPEG'))
{
imagejpeg($dst_img, $imgdir.$file_name,90);
}else if(($imgext=='gif') || ($imgext=='GIF')){
imagegif($dst_img, $imgdir.$file_name,90);
}else if(($imgext=='png') || ($imgext=='PNG')){
imagepng($dst_img, $imgdir.$file_name,5);
}
}
create_image_by_url1($url);
Subscribe to:
Posts (Atom)