This is a discussion on How can we know the number of days between two given dates using PHP? within the PHP Programming forums, part of the Web Development category; How can we know the number of days between two given dates using PHP?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| How can we know the number of days between two given dates using PHP?
__________________ Thanks & Regards Sabari... |
|
#2
| |||
| |||
| hi sabari, Using the following function u can get the no of days between two dates. PHP Code: 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) . "."; which generates If we minus 07/11/2003 from 09/04/2004 we get 421.
__________________ J.Vijayanand |
|
#3
| |||
| |||
| This code is not working for me? Error: Fatal error: Call to undefined function: gregoriantojd() in /home/www/htdocs/photomax_clone/testing/sabari/scalar_error1.php on line 7
__________________ Thanks & Regards Sabari... |
|
#4
| |||
| |||
| I'm using this version of PHP Version 4.3.4?
__________________ Thanks & Regards Sabari... |
|
#5
| |||
| |||
| I think this will work out.. <? $date1 = '2007/09/27'; $date2 = '2007/09/25'; datediff($date1,$date2); function datediff($d1,$d2) { $days = (strtotime($d1) - strtotime($d2)) / (60 * 60 * 24); echo "Number of days between $d1 and $d2 : $days"; } ?>
__________________ Thanks & Regards, Jegan CBK "We will either find a way, or make one!” |
|
#6
| |||
| |||
| hi, her i have given you the function to get year diffrence. it will help you to get age. PHP Code:
__________________ With, J. Jeyaseelan Everything Possible |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Number of days in a month (or last day of a month) | itbarota | HTML, CSS and Javascript Coding Techniques | 2 | 04-28-2008 07:47 PM |
| Show the number of days, hours and seconds till Y3K. | itbarota | HTML, CSS and Javascript Coding Techniques | 1 | 03-10-2008 12:28 AM |
| calculate the number of days in the current month | itbarota | HTML, CSS and Javascript Coding Techniques | 1 | 02-08-2008 05:30 AM |
| How can I calculate the number of days elapsed between two dates? | itbarota | HTML, CSS and Javascript Coding Techniques | 2 | 12-19-2007 08:14 PM |
| how to calculate number of sundays between two dates in javascript | oxygen | HTML, CSS and Javascript Coding Techniques | 1 | 07-30-2007 08:49 AM |
Our Partners |