On Wed, June 14, 2006 11:45 am, [EMAIL PROTECTED] wrote:
I need to calculate no. of days between two dates, actually between
date
stored in DB and today's date.
Almost for sure your best answer is actually in your SQL engine with
something like date_subtract in MySQL.
PHP's date functions
On Wed, June 14, 2006 11:45 am, [EMAIL PROTECTED] wrote:
I need to calculate no. of days between two dates, actually between
date stored in DB and today's date.
If you want to do this via mysql, see:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-type-overview.html
Thanks Ted. Very helpfull.
-afan
On Wed, June 14, 2006 11:45 am, [EMAIL PROTECTED] wrote:
I need to calculate no. of days between two dates, actually between
date stored in DB and today's date.
If you want to do this via mysql, see:
Hi,
I need to calculate no. of days between two dates, actually between date
stored in DB and today's date.
Does anybody has an example I can use?
I found an example on
http://www.developertutorials.com/tutorials/php/calculating-difference-between-dates-php-051018/page1.html
but function
You could just parse the dates out and feed them to mktime(), subtract
the difference between the two (in seconds) and use that to determin the
number of days...
Something like:
?php
$date1=06/01/2006;
$date2 = date('m/d/Y');
echo $date1 -- $date2\n;
list($m,$d,$y) = explode(/,$date1);
$one
[EMAIL PROTECTED] wrote:
I need to calculate no. of days between two dates, actually between date
stored in DB and today's date.
Does anybody has an example I can use?
Your database will have this function. In PostgreSQL:
SELECT data_column - NOW() AS date_diff;
There are similar
Shouldn't be too difficult in PHP.
?php
$yesterday = date(m/d/y, mktime(0,0,0,date(m), date(d) - 1, date(y)));
$today = date(m/d/y);
$secondsdiff = strtotime($today) - strtotime($yesterday);
$minutesdiff = $secondsdiff / 60;
$hoursdiff = $minutesdiff / 60;
$daysdiff = $hoursdiff /
Thanks for all your, very usefull examples.
-afan
Shouldn't be too difficult in PHP.
?php
$yesterday = date(m/d/y, mktime(0,0,0,date(m), date(d) - 1,
date(y)));
$today = date(m/d/y);
$secondsdiff = strtotime($today) - strtotime($yesterday);
$minutesdiff = $secondsdiff / 60;
8 matches
Mail list logo