WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Get a futurist date from today date to your adding date
Categories : PHP, PHP Classes, Date Time Click here to Update Your Picture
naifphp naif php
Date : Aug 22nd 2006
Grade : 4 of 5 (graded 1 times)
Viewed : 2795
File : 4485.zip
Images : Image 1
Search : More code by naifphp naif php
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

- use this class when you want getting a futurist date from today date to date added by you.

- you can add one day or month or year or more or all of them , as you like .

- it can help you to get unix format date , when using ads system deleting automatically after same date you can use unix format .

- it results a difference day,month and year from today date to a futurist date .

GetFuturistDate.class.php
<?php

/*
//------------------------------------------------------------------------------------------------------------
|| @ Script Desc  : Get a futurist date from today date to your adding date
|| @ Version      : 1.0 beta
|| @ Created      : NAIF PHP
|| @ Web Site     : www.naifphp.net
|| @ Date Created : 22 - 8 - 2006
//--------------------------------------------------------------------------------------------------------------
*/


Class GetFuturistDate
{

      var
$date_format = "d / m / Y"; // date formatting day / month / year
     
var $_day        = "0"; // set day
     
var $_month      = "0"; // set month
     
var $_year       = "0"; // set year


     
function FuturistDate($d="0", $m="0", $y="0")
      {
             
$d  = intval (str_replace('-','',$d));
             
$m  = intval (str_replace('-','',$m));
             
$y  = intval (str_replace('-','',$y));

             
$this->_day     = $d;
             
$this->_month   = $m;
             
$this->_year    = $y;

             
$convert = strtotime("$d days $m months $y years ");

              if (
$convert == '-1')
              {
                      die (
"error , in adding date !!");
              }
              else
              {

                     
$ToDay = date("$this->date_format");
                     
$DateToDayInfo = explode('/', $ToDay);

                     
$_FuturistDate = date("$this->date_format", $convert);
                     
$GetFuturistDate = explode('/',$_FuturistDate);

                     
$balance['day']    = str_replace('-','',$GetFuturistDate[0] - $DateToDayInfo[0]);
                     
$balance['month']  = str_replace('-','',$GetFuturistDate[1] - $DateToDayInfo[1]);
                     
$balance['year']   = str_replace('-','',$GetFuturistDate[2] - $DateToDayInfo[2]);


                     
$FuturistDate = array(

                             
/* Output Date '1176843600' */
                             
"UNIX"          =>    $convert,

                             
/* Outputd Futurist Date ' 22 / 8 / 2006' */
                             
"FUTURISTDATE"  =>    $_FuturistDate,

                             
/* Output balance days */
                             
"BDAY"          =>    $balance['day'],

                             
/* Output balance months */
                             
"BMONTH"        =>    $balance['month'],

                             
/* Output balance Years */
                             
"BYEAR"         =>    $balance['year'],

                             
/* Output ToDay Date */
                             
"TODAY"         =>    $ToDay

                             
);

              }

          return
$FuturistDate;

      }
}
?>



Example Usage
<?php

/*
//------------------------------------------------------------------------------------------------------------
|| @ Script Desc  : Get a futurist date from today date to your adding date
|| @ Version      : 1.0 beta
|| @ Created      : NAIF PHP
|| @ Web Site     : www.naifphp.net
|| @ Date Created : 22 - 8 - 2006
//--------------------------------------------------------------------------------------------------------------
*/


include_once ("GetFuturistDate.class.php");

if(! isset (
$_GET['action'] ) )
{

echo
"<title> Example : Get Futurist Date Class </title>".
         
"<h2> Please insert the day , month and year to get a futurist date   </h2>".
         
"Note : Leave any column blank if you don't want to add it .".

         
"<form method=\"get\">".
         
"Day(s) : <BR><input type=\"text\" name=\"d\" ><BR>".
         
"Month(s) : <BR><input type=\"text\" name=\"m\"><BR>".
         
"Year(s) : <BR><input type=\"text\" name=\"y\"><BR>".
         
"<input type=\"hidden\" name=\"action\"><BR>".
         
"<input type=\"submit\" value=\"Get Futurist Date\"></form>";


}
else
{

$d = $_GET['d'];
$m = $_GET['m'];
$y = $_GET['y'];

$obj = new GetFuturistDate();

// extracting all information :)
$my_date         = $obj->FuturistDate($d, $m, $y);

$today           = $my_date["TODAY"];
$futu_date       = $my_date["FUTURISTDATE"];
$date_unix       = $my_date["UNIX"];
$balance_day     = $my_date["BDAY"];
$balance_month   = $my_date["BMONTH"];
$balance_year    = $my_date["BYEAR"];


echo 
"ToDay Date is : " . $today ." <br> \n".
         
"My Futurist Date After ". $d ."day , ". $m ." month ,". $y ."year is : ".$futu_date.
         
"\n<br> My Futurist Date UNIX formatting : ". $date_unix ." <br>\n".
         
" day's difference : ". $balance_day ." , month : ". $balance_month ." , year : " . $balance_year.

         
"\n <br><br><a href=\"?\"> Try Again </a>";

}

?>



A Timing Class
Categories : PHP, PHP Classes, Date Time
A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function.
Categories : PHP, PHP Classes, Calendar, Date Time
pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes
Open and Close your website in fixed times .
Categories : PHP, PHP Classes, Cron, Date Time
Example of using the pcCalendar class, article 1468 on weberdev.com. Calendar example.
Categories : PHP, Date Time, PHP Classes, Calendar
Validator - A PHP class that can can be used for validating Email IDs and Dates
Categories : PHP, PHP Classes, Data Validation, Email, Date Time
A time measuring and performance benchmarking class
Categories : PHP, PHP Classes, Testing, Debugging, Date Time
Bs_StopWatch is a class to measure time intervals in microseconds.
Categories : PHP, Date Time, PHP Classes
Customizable Calendar Class
Categories : HTML and PHP, Date Time, PHP, PHP Classes, Calendar
a class that uses microtime() to provide easy calculation of elapsed times
Categories : Date Time, PHP, PHP Classes
very simple ftp class
Categories : PHP, PHP Classes, FTP
PHP Paypal IPN Integration Class v1.0.0
Categories : PHP, PHP Classes, Payment Gateways
Create HTML forms dynamicly using Javascript & PHP
Categories : PHP, PHP Classes, Java Script
The class to check load time of your script VERY usefull for relatively slow applications, but not only..
Categories : PHP, PHP Classes, Debugging
usercounter class
Categories : PHP, PHP Classes, Databases, MySQL, Environment Variables