Jump to content

Recommended Posts

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

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/237468-dates-headache/
Share on other sites

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";

?>

Link to comment
https://forums.phpfreaks.com/topic/237468-dates-headache/#findComment-1220258
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.