Login   Register  
PHP Classes
elePHPant
Icontem

File: example_date_span.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Victor Hugo Cardenas Varon  >  Date Span  >  example_date_span.php  >  Download  
File: example_date_span.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Date Span
Calculate and spell the timespan between two dates
Author: By
Last change: added examples with in german
Date: 2004-11-21 08:59
Size: 2,060 bytes
 

Contents

Class file image Download
<?php
/**
* Test Script
* Class Date Span - clase_date_span.inc.php
*
**/
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento sin t&iacute;tulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
include("clase_date_span.inc.php");

$ds = new date_span();

echo 
"<b>This example was made with current system date 2000-11-16</b><br><br>";
//*** assuming that the system date is 2004-11-16
$date "2004-10-25";
echo 
"$date - today: ".$ds->calculate_span($date); //2004-10-25 - today: 22 dias
echo "<br>";

$date "2004-11-16";
echo 
"$date - today: ".$ds->calculate_span($date); //2004-11-16 - today: hoy mismo
echo "<br>";


$date "1989-01-03";
echo 
"$date - today: ".$ds->calculate_span($date); //1989-01-03 - today: 15 aņos, 10 meses y 13 dias

echo "<br>";

$date "2004-09-16";
echo 
"$date - today: ".$ds->calculate_span($date); //2004-09-16 - today: 2 meses
echo "<br>";

//switch language to english
$ds->set_language("en");

$date "2003-09-30";
echo 
"$date - today: ".$ds->calculate_span($date); //2003-09-30 - today: 1 year, 1 month and 17 days
echo "<br>";

//switch language to german
$ds->set_language("de");

$date "2003-09-30";
echo 
"$date - today: ".$ds->calculate_span($date); //2003-09-30 - today: 1 Jahr, 1 Monat und 17 Tage

echo "<br>";

$date "2000-01-17";
echo 
"$date - today: ".$ds->calculate_span($date); //2000-01-17 - today: 4 Jahre, 9 Monate und 30 Tage
echo "<br>";


//now, is passed a second date (the system date is not used)
$ds->set_language("en");
$date "1999-10-10";
$date2 "2001-02-13";
echo 
"$date - $date2: ".$ds->calculate_span($date$date2); //1999-10-10 - 2001-02-13: 1 year, 4 months and 3 days
echo "<br>";

$date "2000-12-01";
$date2 "2002-01-01";
echo 
"$date - $date2: ".$ds->calculate_span($date$date2); //2000-12-01 - 2002-01-01: 1 year and 1 month
echo "<br>";

?>
</body>
</html>