Andrew R Posted April 30, 2007 Share Posted April 30, 2007 Hi The below script pulls a date from the database depending on what user is selected and then adds on 14 days (2 weeks). The problem is the script is not giving me the desired output. Any ideas? Cheers <? $date = $row_thing['date']; $nxt = date('$date', strtotime('+14 days')); echo $nxt; ?> Link to comment https://forums.phpfreaks.com/topic/49365-adding-dates-from-a-database/ Share on other sites More sharing options...
pocobueno1388 Posted April 30, 2007 Share Posted April 30, 2007 How is your date formated in the database? Link to comment https://forums.phpfreaks.com/topic/49365-adding-dates-from-a-database/#findComment-241891 Share on other sites More sharing options...
Andrew R Posted April 30, 2007 Author Share Posted April 30, 2007 How is your date formated in the database? Y-m-d date("Y-m-d") Link to comment https://forums.phpfreaks.com/topic/49365-adding-dates-from-a-database/#findComment-241895 Share on other sites More sharing options...
pocobueno1388 Posted April 30, 2007 Share Posted April 30, 2007 Hmmm....I have the same exact line in one of my scripts, the only difference is I have the +14 days in double quotes and it works fine. Maybe give that a try? I doubt it makes a difference, but it's worth a go. Oh, maybe your variable needs to be in double quotes as well. $nxt = date("$date", strtotime("+14 days")); Link to comment https://forums.phpfreaks.com/topic/49365-adding-dates-from-a-database/#findComment-241900 Share on other sites More sharing options...
Andrew R Posted April 30, 2007 Author Share Posted April 30, 2007 Hmmm....I have the same exact line in one of my scripts, the only difference is I have the +14 days in double quotes and it works fine. Maybe give that a try? I doubt it makes a difference, but it's worth a go. Oh, maybe your variable needs to be in double quotes as well. $nxt = date("$date", strtotime("+14 days")); It's working now but its not adding on the 14 days. Just echoing the date from the database? Link to comment https://forums.phpfreaks.com/topic/49365-adding-dates-from-a-database/#findComment-241904 Share on other sites More sharing options...
Barand Posted April 30, 2007 Share Posted April 30, 2007 <?php $date = '2007-04-30'; echo date ('Y-m-d', strtotime ("$date +14 days")); ?> Link to comment https://forums.phpfreaks.com/topic/49365-adding-dates-from-a-database/#findComment-241908 Share on other sites More sharing options...
Andrew R Posted April 30, 2007 Author Share Posted April 30, 2007 <?php $date = '2007-04-30'; echo date ('Y-m-d', strtotime ("$date +14 days")); ?> Worked!! Thanks Link to comment https://forums.phpfreaks.com/topic/49365-adding-dates-from-a-database/#findComment-241922 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.