Jump to content

Dates headache :-(


herghost

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.