Re: [PHP] Calculating difference between two days

2006-06-15 Thread Richard Lynch
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

Re: [PHP] Calculating difference between two days

2006-06-15 Thread tedd
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

Re: [PHP] Calculating difference between two days

2006-06-15 Thread afan
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:

[PHP] Calculating difference between two days

2006-06-14 Thread afan
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

Re: [PHP] Calculating difference between two days

2006-06-14 Thread Brad Bonkoski
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

Re: [PHP] Calculating difference between two days

2006-06-14 Thread D. Dante Lorenso
[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

Re: [PHP] Calculating difference between two days

2006-06-14 Thread tg-php
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 /

Re: [PHP] Calculating difference between two days

2006-06-14 Thread afan
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;