herghost Posted May 25, 2011 Share Posted May 25, 2011 Hi all, I am having bit of a headache in trying to achieve what I want! Basically I have a date coming into the script as this format: Tue May 24 18:51:38 +0000 2011 These are the steps I wish to do an not quite sure how! 1. Make date read: May 24 2011 2. Add 6 Months to date and store as new variable For part 2 I am guessing I can do something like: <?php $futuredate = strtotime('+6 months', $date) ?>; But part one is stumping me! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/237468-dates-headache/ Share on other sites More sharing options...
herghost Posted May 25, 2011 Author Share Posted May 25, 2011 Got it! echo $joined; echo '<br>'; $date = strtotime($joined); echo date('jS F Y', $date); echo '<br>'; $date = strtotime('+6 months', $date); echo date('jS F Y', $date); Quote Link to comment https://forums.phpfreaks.com/topic/237468-dates-headache/#findComment-1220256 Share on other sites More sharing options...
Maq Posted May 25, 2011 Share Posted May 25, 2011 You have to use a combination of date and strtotime: ini_set ("display_errors", "1"); error_reporting(E_ALL); $s = strtotime("Tue May 24 18:51:38 +0000 2011"); $today = date('F d Y', $s); $future = date('F d Y', (strtotime('+6 month', $s))); echo "today->$today \n future-> $future"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/237468-dates-headache/#findComment-1220258 Share on other sites More sharing options...
herghost Posted May 25, 2011 Author Share Posted May 25, 2011 Thanks, i guess that is the same way of achieving the same thing? How would I calculate the number of days between the two? I have tried $aDays = floor(abs($readydate - $njoined) / 86400); but it returns 0? Quote Link to comment https://forums.phpfreaks.com/topic/237468-dates-headache/#findComment-1220271 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.