Free Web Hosting Provider - Web Hosting - E-commerce - High Speed Internet - Free Web Page
Search the Web

Get the Number of Day Different from Current Date

This programmer is a very simple and use full code for you, This is a small function with retunes the day when you pass the old date, Get Number of day from your birth date. Example:
You have born on 1970 and you like to know about how many day up to now you have been in this world. and if you like to display some new data from a database say.

Script Name : SafgetDiff() Version : 1.1
Developer : Safras Ahamed, Helped by Ramesh Date 03/13/2003
Used Functions : explode(), mktime(), floor(), list()
 

<?
$datex
= "2003-02-10"
$number_of_day_left = SafgetDiff($datex)

if (
$datex < 10 ) {
print "You can display here new image in front of your product"
}else{
//just leave it new product not found
}

//========This is the function
function
SafgetDiff($d) {
list($y,$m,$d) = explode("-",$d);
$timestamp = mktime(0,0,0,$m,$d,$y);
$d2 = time();
$diff = $d2 - $timestamp;
$days = floor($diff / 86400); //86400 = 60*60*24 (sec*min*hr) and floor will give you a base (not .0023 no)
return $days;
}

/*NOTE :
Please use the date format when your are saving to database like date('y-m-d'), bcos MySql database date format is yyyy-mm-dd (2003-02-18) so don't mix up this*/
?>

 
Web Master : Safras Ahamed, Email : safras@ArabChat.Org
Copyright 2003 ArabChat Network