phoenixx Posted June 4, 2010 Share Posted June 4, 2010 I have a database that outputs the following: $signupdoy = ($row['clients_signupdoy']); // Signup Numeric Day of Year $signupdate = ($row['clients_signupdate']); // Signup 2 Digit Date $signupmonth = ($row['clients_signupmonth']); // Signup 2 Digit Month $signupyear = ($row['clients_signupyear']); // Signup 4 Digit Year I've searched the mktime and strtotime functions , but seem to be drawing a blank. I could really use some help on the following: Converting the signup date to a date 7 days later (to know when the free trial ends). I know I could just do $signupdoy+7 but I need to show it as an actual date on the client's account page. Converting the signup date to a monthly billing date, keeping in mind that if the user signs up on the 29th, 30, or 31st that there are some days that don't go that high. Ensuring that the 7 day and monthly anniversary dates are compliant when going from one year to the next. I would like to output the code like: dd.mm.yyyy I know it's got to be just a few lines of code, but everything I've tried has come up negative. Any help the forum could give me would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/203882-converting-day-of-year-to-real-date-in-the-future/ Share on other sites More sharing options...
TheBG Posted June 4, 2010 Share Posted June 4, 2010 Post the code to create the date. Sorry, my bad. Your looking for a way to do it. strtotime() works to get a times tamp. Then just add the number of seconds in 7 days and add it to the time stamp. Finally, use date() to format the time stamp. Quote Link to comment https://forums.phpfreaks.com/topic/203882-converting-day-of-year-to-real-date-in-the-future/#findComment-1067818 Share on other sites More sharing options...
phoenixx Posted June 4, 2010 Author Share Posted June 4, 2010 The strtotime function seems to be getting screwed up when I replace the date("m-d-y" with date("$signupmonth-$signupdate-$signupyear" variables. Quote Link to comment https://forums.phpfreaks.com/topic/203882-converting-day-of-year-to-real-date-in-the-future/#findComment-1067824 Share on other sites More sharing options...
gwolgamott Posted June 4, 2010 Share Posted June 4, 2010 Why not just use the getdate() and use the 0 for the number of seconds since epoch. Then just add seven days worth of seconds to the current date and use that number as a reference. http://us.php.net/manual/en/function.getdate.php $time_I_reg = getdate(); echo $time_I_reg[0]; // will display the seconds since epoch for that that date. $temp_time = $time_I_reg[0] + $sevendaysofseconds; // will add seven days $time_ends = getdate($temp_time); echo $time_ends[month]." ".$time_ends[mday]; Quote Link to comment https://forums.phpfreaks.com/topic/203882-converting-day-of-year-to-real-date-in-the-future/#findComment-1067826 Share on other sites More sharing options...
TheBG Posted June 4, 2010 Share Posted June 4, 2010 You lost me. You're talking about strtotime() and showing date(). Try $timeStamp = strtotime("$signupmonth-$signupdate-$signupyear") Quote Link to comment https://forums.phpfreaks.com/topic/203882-converting-day-of-year-to-real-date-in-the-future/#findComment-1067829 Share on other sites More sharing options...
jcbones Posted June 4, 2010 Share Posted June 4, 2010 * Converting the signup date to a date 7 days later (to know when the free trial ends). I know I could just do $signupdoy+7 but I need to show it as an actual date on the client's account page. * Converting the signup date to a monthly billing date, keeping in mind that if the user signs up on the 29th, 30, or 31st that there are some days that don't go that high. * Ensuring that the 7 day and monthly anniversary dates are compliant when going from one year to the next. //07.02.2010 = sign up date. $date = date('d.m.Y',strtotime('+7 days',strtotime("$signupdate-$signupmonth-$signupyear"))); //14.02.2010 = output date. Quote Link to comment https://forums.phpfreaks.com/topic/203882-converting-day-of-year-to-real-date-in-the-future/#findComment-1067844 Share on other sites More sharing options...
TheBG Posted June 4, 2010 Share Posted June 4, 2010 And there you go. Has the code and didn't learn a thing. Gosh you sure are smart jcbones, you knew the answer. Quote Link to comment https://forums.phpfreaks.com/topic/203882-converting-day-of-year-to-real-date-in-the-future/#findComment-1067847 Share on other sites More sharing options...
jcbones Posted June 4, 2010 Share Posted June 4, 2010 I'm sorry, he asked a question. He knew what functions to use. He couldn't figure it out. So yes, he has the code, now he knows the answer. I'm not that smart, I just had help when I started out. The same kind of help I just gave, and not vague suggestions dancing around an answer. BTW, strtotime() does care which way you insert the date into it. Giving it a "mm-dd-yyyy" will return the wrong date. It looks for "dd-mm-yyyy". Quote Link to comment https://forums.phpfreaks.com/topic/203882-converting-day-of-year-to-real-date-in-the-future/#findComment-1067856 Share on other sites More sharing options...
phoenixx Posted June 4, 2010 Author Share Posted June 4, 2010 Many thanks to both TheBG & jcbones. Got it figured out before the posts, but jcbjones code is cleaner than mine. Wound up using the following. <? echo date('m.d.Y',strtotime('+7 days',strtotime("$signupdate-$signupmonth-$signupyear"))) . " (" . (($acctsignupdoy+6)-date('z')) . " days)";?> Thanks again for all the help! Quote Link to comment https://forums.phpfreaks.com/topic/203882-converting-day-of-year-to-real-date-in-the-future/#findComment-1067866 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.