timmah1 Posted January 15, 2008 Share Posted January 15, 2008 Hi How would I take this code $start = date("Y-m-d"); $formatted_date = date("M j, Y", strtotime($start)); And make it echo 3 days ahead? Meaning, today's date is Jan. 15, 2008, I would like this code to be able to distinguish 3 days ahead, meaning it would echo out Jan. 18, 2008. I've tried this, but it only shows the 3 $start = date("Y-m-d"); $formatted_date = date("M j, Y", strtotime($start)); $ends = $formatted_date+3; Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/86151-solved-date-produce/ Share on other sites More sharing options...
cooldude832 Posted January 15, 2008 Share Posted January 15, 2008 <?php $start = date("Y-m-d"); $formatted_date = date("M j, Y", strtotime("+3 Days", $start)); echo "Start: ".$start."<br />Formatted: ".$formatted_date; ?> Quote Link to comment https://forums.phpfreaks.com/topic/86151-solved-date-produce/#findComment-439972 Share on other sites More sharing options...
timmah1 Posted January 15, 2008 Author Share Posted January 15, 2008 With that, it displays this Start: 2008-01-15 Formatted: Jan 3, 1970 Quote Link to comment https://forums.phpfreaks.com/topic/86151-solved-date-produce/#findComment-439980 Share on other sites More sharing options...
cooldude832 Posted January 15, 2008 Share Posted January 15, 2008 your version of php doesn't support a start date in that format so try (the yyyy-mm-dd) so try <?php $start = date("U"); $formatted_date = date("M j, Y", strtotime("+3 Days", $start)); echo "Start: ".$start."<br />Formatted: ".$formatted_date; ?> really if you are strating at NOW() you can ignore the start and just do <?php $formatted_date = date("M j, Y", strtotime("+3 Days")); echo "Formatted: ".$formatted_date; ?> Quote Link to comment https://forums.phpfreaks.com/topic/86151-solved-date-produce/#findComment-439985 Share on other sites More sharing options...
timmah1 Posted January 15, 2008 Author Share Posted January 15, 2008 Works perfect. Thank you very much. What version is this php then? hmmm Thank you Quote Link to comment https://forums.phpfreaks.com/topic/86151-solved-date-produce/#findComment-439992 Share on other sites More sharing options...
cooldude832 Posted January 15, 2008 Share Posted January 15, 2008 strtotime is on the flaw list of php for not being able to do things consistently which is a problem cause it doesn't know yyyy-mm-dd from yyyy-dd-mm from mm-dd-yyyy from dd-mm-yyyy Quote Link to comment https://forums.phpfreaks.com/topic/86151-solved-date-produce/#findComment-439998 Share on other sites More sharing options...
timmah1 Posted January 15, 2008 Author Share Posted January 15, 2008 Thank you, you are very much a 'super guru' I really appreciate your help Quote Link to comment https://forums.phpfreaks.com/topic/86151-solved-date-produce/#findComment-440005 Share on other sites More sharing options...
PFMaBiSmAd Posted January 15, 2008 Share Posted January 15, 2008 The problem with the above code is that the second parameter of strtotime() is a UNIX Timestamp. The original code inserted a formatted string instead and produces a Notice warning and outputs a 1970 date. Quote Link to comment https://forums.phpfreaks.com/topic/86151-solved-date-produce/#findComment-440009 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.