emilyfrazier Posted October 16, 2006 Share Posted October 16, 2006 Hi all,I am still fairly new to PHP and mySQL. I have read all the tutorials on dates, yet I'm still not seeing the light today.So I have a field in my database called 'date_joined' that holds a timestamp when a users signs up for membership. I need to make a report that tells me all the memberships that will expire within the next 30 days (memberships are for 1 year). Is there a way to take my field and use mktime to add 1 year to it? I assume it's possible through a function that breaks up the date and then subs them in to a mktime string, but I was wondering if there is an easier way around it? I would really appreciate any help in advance. Thanks so much,eef Quote Link to comment Share on other sites More sharing options...
neoform Posted October 16, 2006 Share Posted October 16, 2006 is it a `datetime` timestamp ?[code]date('Y-m-d H:i:s', time() + (365 * 24 *60 * 60));[/code] Quote Link to comment Share on other sites More sharing options...
emilyfrazier Posted October 16, 2006 Author Share Posted October 16, 2006 Thanks so much for the help...it doesn't work quite right. It is taking today's date if I use this code. I tried:$yr = date('Y-m-d H:i:s', time($data['date_joined']) + (365 * 24 *60 * 60));And it gives me today's date a year from now...I need it to take a year from now from the 'date_joined' field...thanks againeef Quote Link to comment Share on other sites More sharing options...
emilyfrazier Posted October 16, 2006 Author Share Posted October 16, 2006 I got it working using this:[code] $datemysqlyr = date ( "Y m d H:i:s" , strtotime ( $data [ 'date_joined' ]) + (365 * 24 *60 * 60)); [/code]Thanks very much for your help!!eef Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 16, 2006 Share Posted October 16, 2006 You can also use:[code]<?php $datemysqlyr = date('Y m d H:i:s',strottime($data [ 'date_joined' ] . ' + 1 year')); ?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.