Friday 10, February 2012
Welcome Guest, Register | Login  
      Home    |    Tutorials    |    Free Ebooks    |    Free Scripts    |    Articles    |    Blog     |    Forum    |    About Us    |    Contact Us

  Difference Between two dates using php

This function will return the number of days elapsed between two dates.
Cut & Paste Script

function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);
$end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
return $end_date - $start_date;
}

Now let us see how we use this function:

$date1="07/11/2003";
$date2="09/04/2004";

print "If we minus " . $date1 . " from " . $date2 . " we get " . dateDiff("/", $date2, $date1) . ".";

 
   
     RELATED SCRIPTS
 
Email validation using regular expression php
Here is a php script to validate email address. We are using regular expression for validation....more »
Category : PHP Examples Hits : 766
   
Reversing a string using php
This code example will reverse the given string using php....more »
Category : PHP Examples Hits : 292
   
sending email using mail function in php
An example to send email using php mail() function....more »
Category : PHP Examples Hits : 660
   
Exporting data from MySql table to CSV using PHP
Here is a code example for exporting data from MySql table to a CSV File. CSV file format is a file type that stores tabular data usually processed in applications like Microsoft Excel....more »
Category : PHP Examples Hits : 978
   
creating xml file using php
Here is a script to create xml file using php DOM....more »
Category : PHP Examples Hits : 439
   
   
SCRIPT CATEGORIES
 
  C Programs
C Programs scripts
  C++ Programs
C++ Programs scripts
  Java Programs
Java Programs scripts
  JavaScript Examples
JavaScript Examples scripts
  PHP Examples
PHP Examples scripts
  VBScript Examples
VBScript Examples scripts
 
 
 
POPULAR E-BOOKS
 
Download Creating XPCOM Components  Ebook Creating XPCOM Components
   
Download BMA s Internet Marketing Articles Vol I  Ebook BMA s Internet Marketing Articles Vol I
   
Download 1000 Java Tips  Ebook 1000 Java Tips
   
Download 5 Simple Ways To Boost Up Your Website Ebook 5 Simple Ways To Boost Up Your Website
   
Download How To Really Earn Big With Your Own Internet Business  Ebook How To Really Earn Big With Your Own Internet Business
   
 
Studiesinn.com © 2012 All Rights Reserved.
Website Designed & Developed by TechXprtz