louis_coetzee Posted September 2, 2009 Share Posted September 2, 2009 Hi people! I would like to get after the one I give my website. $date = '19012009'; newdate must be a day after $date or before $date //must be like the one's below, just need the math. $date_before = '18012009'; $date_after = '20012009'; Please help, and thanks. Link to comment https://forums.phpfreaks.com/topic/172804-get-the-date-after-the-given-date-please-check-this-out/ Share on other sites More sharing options...
mystery_man Posted September 2, 2009 Share Posted September 2, 2009 I had my fair share of trouble with the php date stuff. Try this - it might help you in the right direction: //get the current time, or whatever time you're workign with as timestamp $date = time(); //Get tomorrow's date $day_after = strtotime("tomorrow",$date); //get yesterday's date $day_previous = strtotime("yesterday",$date); //then use strftime to format the date as you want it. $day_after_formatted = strftime("%Y-%m-%d", $day_after); $day_previous_formatted = strftime("%Y-%m-%d", $day_previous); Link to comment https://forums.phpfreaks.com/topic/172804-get-the-date-after-the-given-date-please-check-this-out/#findComment-910814 Share on other sites More sharing options...
louis_coetzee Posted September 2, 2009 Author Share Posted September 2, 2009 I had my fair share of trouble with the php date stuff. Try this - it might help you in the right direction: //get the current time, or whatever time you're workign with as timestamp $date = time(); //Get tomorrow's date $day_after = strtotime("tomorrow",$date); //get yesterday's date $day_previous = strtotime("yesterday",$date); //then use strftime to format the date as you want it. $day_after_formatted = strftime("%Y-%m-%d", $day_after); $day_previous_formatted = strftime("%Y-%m-%d", $day_previous); Thanks a lot, this looks like what I was looking for. Link to comment https://forums.phpfreaks.com/topic/172804-get-the-date-after-the-given-date-please-check-this-out/#findComment-910817 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.