alin19 Posted March 19, 2008 Share Posted March 19, 2008 i'm trying to make a script and i stumbled on a problem i have 2 insert spaces first: doday's date: ex 19.03.2008 second: number of days: ex 90 and i want to insert in a data base the day that will be aftern 90 days: ex 18.06.2008 Quote Link to comment Share on other sites More sharing options...
Caesar Posted March 19, 2008 Share Posted March 19, 2008 <?php $date['today'] = time(); $date['90_days'] = date("d.m.Y",($date['today']+7776000)); ?> Quote Link to comment Share on other sites More sharing options...
Caesar Posted March 19, 2008 Share Posted March 19, 2008 Also...if you're inserting into a database, it's just good practice to store as either a time stamp, or as a properly formatted date. Makes life easier. Quote Link to comment Share on other sites More sharing options...
alin19 Posted March 19, 2008 Author Share Posted March 19, 2008 can you explain a little the code? what is 7776000? i could have 120 days; 90 days was just an example Quote Link to comment Share on other sites More sharing options...
Barand Posted March 19, 2008 Share Posted March 19, 2008 INSERT INTO tablename (datecol) VALUES (CURDATE() + INTERVAL 90 DAY) Quote Link to comment Share on other sites More sharing options...
Caesar Posted March 19, 2008 Share Posted March 19, 2008 That will also work. Though after reading his last reply may want to make the number of days a variable he can define/set based on whatever conditions exist. Quote Link to comment Share on other sites More sharing options...
Caesar Posted March 19, 2008 Share Posted March 19, 2008 Wait....Barand, are you assuming he is storing the dates in a standard format? Don't think he is. Quote Link to comment Share on other sites More sharing options...
Barand Posted March 19, 2008 Share Posted March 19, 2008 It won't be long before he realises d.m.y is as useless as a chocolate teapot when used as a db date format. And if the number of days is a variable $sql = "INSERT INTO tablename (datecol) VALUES (CURDATE() + INTERVAL $days DAY)"; 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.