Re: [PHP] Augmenting an old date
Thanks Tom, for the excellent help! Seems like 'strtotime' function was what was needed! Regards, Andre On Sunday 19 May 2002 01:06 am, you wrote: > Hi > A slightly more efficeint way :) > > $start = "2002-01-01"; > $expire = date("Y-m-d",strtotime("$start +30 days")); > echo $expire.""; > ?> > > Tom > > At 02:03 PM 19/05/2002, Andre Dubuc wrote: > >Two columns in my PostgreSQL db are type 'date' (formatted '-mm-dd'): > >'start_date' and 'expiry_date'. What I cannot seem to figure out is how to > >augment the 'expiry_date' either by 30 days, 60 days, or 1 year. > > > >I've tried the date function in PHP (getdate) but the problem is that it > >appears to need a timestamp of "today". The dates that I'm trying to > > augment are sometimes a year or two ago. > > > >This doesn't work: > > > >$new_expiry_date = $expiry_date("Y-m-d", mktime(0,0,0, date(Y), date(m), > >date(d) + 60))); > > > >I assume it's because the '$expiry_date' should be simply 'date', but that > >would give the current date which is not what is wanted. Is there anyway > > to set 'date' as '$expiry_date'? > > > >Suggestions, admonitions, and general advice will be greatly appreciated. > >Btw, I've searched the archives, and haven't found anything quite on this > >topic. > > > >Tia, > >Andre > > > > > >-- > >Please pray the Holy Rosary to end the holocaust of abortion. > >Remember in your prayers the Holy Souls in Purgatory. > > > >May God bless you abundantly in His love! > >For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/ > > > >-- > >PHP General Mailing List (http://www.php.net/) > >To unsubscribe, visit: http://www.php.net/unsub.php -- Please pray the Holy Rosary to end the holocaust of abortion. Remember in your prayers the Holy Souls in Purgatory. May God bless you abundantly in His love! For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Augmenting an old date
Wow this is a pretty cool function. I was playing with it and you can add like +30 days + 99 seconds together and it works. -Original Message- From: Tom Rogers [mailto:[EMAIL PROTECTED]] Sent: May 19, 2002 1:07 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [PHP] Augmenting an old date Hi A slightly more efficeint way :) "; ?> Tom At 02:03 PM 19/05/2002, Andre Dubuc wrote: >Two columns in my PostgreSQL db are type 'date' (formatted '-mm-dd'): >'start_date' and 'expiry_date'. What I cannot seem to figure out is how to >augment the 'expiry_date' either by 30 days, 60 days, or 1 year. > >I've tried the date function in PHP (getdate) but the problem is that it >appears to need a timestamp of "today". The dates that I'm trying to augment >are sometimes a year or two ago. > >This doesn't work: > >$new_expiry_date = $expiry_date("Y-m-d", mktime(0,0,0, date(Y), date(m), >date(d) + 60))); > >I assume it's because the '$expiry_date' should be simply 'date', but that >would give the current date which is not what is wanted. Is there anyway to >set 'date' as '$expiry_date'? > >Suggestions, admonitions, and general advice will be greatly appreciated. >Btw, I've searched the archives, and haven't found anything quite on this >topic. > >Tia, >Andre > > >-- >Please pray the Holy Rosary to end the holocaust of abortion. >Remember in your prayers the Holy Souls in Purgatory. > >May God bless you abundantly in His love! >For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/ > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.361 / Virus Database: 199 - Release Date: 07/05/02 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.361 / Virus Database: 199 - Release Date: 07/05/02 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Augmenting an old date
Hi A slightly more efficeint way :) "; ?> Tom At 02:03 PM 19/05/2002, Andre Dubuc wrote: >Two columns in my PostgreSQL db are type 'date' (formatted '-mm-dd'): >'start_date' and 'expiry_date'. What I cannot seem to figure out is how to >augment the 'expiry_date' either by 30 days, 60 days, or 1 year. > >I've tried the date function in PHP (getdate) but the problem is that it >appears to need a timestamp of "today". The dates that I'm trying to augment >are sometimes a year or two ago. > >This doesn't work: > >$new_expiry_date = $expiry_date("Y-m-d", mktime(0,0,0, date(Y), date(m), >date(d) + 60))); > >I assume it's because the '$expiry_date' should be simply 'date', but that >would give the current date which is not what is wanted. Is there anyway to >set 'date' as '$expiry_date'? > >Suggestions, admonitions, and general advice will be greatly appreciated. >Btw, I've searched the archives, and haven't found anything quite on this >topic. > >Tia, >Andre > > >-- >Please pray the Holy Rosary to end the holocaust of abortion. >Remember in your prayers the Holy Souls in Purgatory. > >May God bless you abundantly in His love! >For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/ > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Augmenting an old date
Hi You need to use the strtodate function which converts to a time stamp a date string and you can offset it by a number of days or whatever something like this "; ?> Tom At 02:03 PM 19/05/2002, Andre Dubuc wrote: >Two columns in my PostgreSQL db are type 'date' (formatted '-mm-dd'): >'start_date' and 'expiry_date'. What I cannot seem to figure out is how to >augment the 'expiry_date' either by 30 days, 60 days, or 1 year. > >I've tried the date function in PHP (getdate) but the problem is that it >appears to need a timestamp of "today". The dates that I'm trying to augment >are sometimes a year or two ago. > >This doesn't work: > >$new_expiry_date = $expiry_date("Y-m-d", mktime(0,0,0, date(Y), date(m), >date(d) + 60))); > >I assume it's because the '$expiry_date' should be simply 'date', but that >would give the current date which is not what is wanted. Is there anyway to >set 'date' as '$expiry_date'? > >Suggestions, admonitions, and general advice will be greatly appreciated. >Btw, I've searched the archives, and haven't found anything quite on this >topic. > >Tia, >Andre > > >-- >Please pray the Holy Rosary to end the holocaust of abortion. >Remember in your prayers the Holy Souls in Purgatory. > >May God bless you abundantly in His love! >For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/ > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Augmenting an old date
Here's a nice article all about dates http://www.phpbuilder.com/columns/akent2610.ph p3 On page 6 of that article it shows a function for adding years, months, days ... to a date. function DateAdd ($interval, $number, $date) { $date_time_array = getdate($date); $hours = $date_time_array["hours"]; $minutes = $date_time_array["minutes"]; $seconds = $date_time_array["seconds"]; $month = $date_time_array["mon"]; $day = $date_time_array["mday"]; $year = $date_time_array["year"]; switch ($interval) { case "": $year +=$number; break; case "q": $year +=($number*3); break; case "m": $month +=$number; break; case "y": case "d": case "w": $day+=$number; break; case "ww": $day+=($number*7); break; case "h": $hours+=$number; break; case "n": $minutes+=$number; break; case "s": $seconds+=$number; break; } $timestamp = mktime($hours ,$minutes, $seconds,$month ,$day, $year); return $timestamp; } -Original Message- From: Andre Dubuc [mailto:[EMAIL PROTECTED]] Sent: May 19, 2002 12:03 AM To: [EMAIL PROTECTED] Subject: [PHP] Augmenting an old date Two columns in my PostgreSQL db are type 'date' (formatted '-mm-dd'): 'start_date' and 'expiry_date'. What I cannot seem to figure out is how to augment the 'expiry_date' either by 30 days, 60 days, or 1 year. I've tried the date function in PHP (getdate) but the problem is that it appears to need a timestamp of "today". The dates that I'm trying to augment are sometimes a year or two ago. This doesn't work: $new_expiry_date = $expiry_date("Y-m-d", mktime(0,0,0, date(Y), date(m), date(d) + 60))); I assume it's because the '$expiry_date' should be simply 'date', but that would give the current date which is not what is wanted. Is there anyway to set 'date' as '$expiry_date'? Suggestions, admonitions, and general advice will be greatly appreciated. Btw, I've searched the archives, and haven't found anything quite on this topic. Tia, Andre -- Please pray the Holy Rosary to end the holocaust of abortion. Remember in your prayers the Holy Souls in Purgatory. May God bless you abundantly in His love! For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.361 / Virus Database: 199 - Release Date: 07/05/02 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.361 / Virus Database: 199 - Release Date: 07/05/02 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Augmenting an old date
Two columns in my PostgreSQL db are type 'date' (formatted '-mm-dd'): 'start_date' and 'expiry_date'. What I cannot seem to figure out is how to augment the 'expiry_date' either by 30 days, 60 days, or 1 year. I've tried the date function in PHP (getdate) but the problem is that it appears to need a timestamp of "today". The dates that I'm trying to augment are sometimes a year or two ago. This doesn't work: $new_expiry_date = $expiry_date("Y-m-d", mktime(0,0,0, date(Y), date(m), date(d) + 60))); I assume it's because the '$expiry_date' should be simply 'date', but that would give the current date which is not what is wanted. Is there anyway to set 'date' as '$expiry_date'? Suggestions, admonitions, and general advice will be greatly appreciated. Btw, I've searched the archives, and haven't found anything quite on this topic. Tia, Andre -- Please pray the Holy Rosary to end the holocaust of abortion. Remember in your prayers the Holy Souls in Purgatory. May God bless you abundantly in His love! For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php