cjbeck71081 Posted September 17, 2008 Share Posted September 17, 2008 Ok, so i am having a bear of a time trying calculate dates. Any help would be apprecaited. So I am timestamping dates in SQL entries using the "INSERT INTO table (`mydate`) VALUES (CURDATE())" This is populating the database with a date similar to this: 2008-09-17 This allows me to do a query of the database by saying "SELECT * FROM table WHERE mydate < CURDATE() - INTERVAL 30 DAY"; This part works great.. then I can send notifications to people who are past 30 days, and all are happy. But now I am trying to display date information in a table for the customer to see. For example... if Bob signed up for an account he'll have a field for su_date(signup date) and it would get '2008-09-17'. If I then wanted to make a table for a client that said... Bob signed up on 09-17-2008 and then calculate his renewel date of 30 days later... by saying Bob needs to renew by 10-17-2008. How would i do that? I have tried taking the value of mydate from the table and adding 30 to it... that just adds 30 years to the date. I'm sure i can reorder the numbers and add form there, but what a mess. Any ideas or methods would be awesome. Thanks Guys CJ Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted September 17, 2008 Share Posted September 17, 2008 Umm, i'd use a combination of date() and strtotime() Something like: $date = '2008-09-17'; echo date('d-m-Y',strtotime($date)+60*60*24*30); Quote Link to comment Share on other sites More sharing options...
Barand Posted September 17, 2008 Share Posted September 17, 2008 or $date = '2008-09-17'; echo date('m-d-Y',strtotime("+30 days $date")); 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.