Jump to content

subtract a month from a date()


Paul-D

Recommended Posts

Do I relay have to do all this in PHP 5.0?

<?php
$Date = time();
$Month = date('m' ,$Date);
$Year = date('Y' ,$Date);
$Month -= 1;
if ($Month == 0)
  {
   $Month = 12;
   $Year -= 1;
  }
$Date = $Year . "-" . $Month . "-01";
echo $Date;
?>

Link to comment
Share on other sites

Thanks
echo date('Y-m-d', strtotime('first day of last month')); 
is beeter than

$date = new DateTime('first day of last month');

But how do I get a php.ini into the system for future class related programming

I have
[Date]
date.timezone=Europe/London
 

Will it be picked up automatically or as a shared server be ignored?

 

Link to comment
Share on other sites

As I had to do, you should contact your hosting support people and TELL them you want your PHP.ini file to indicate the timezone that you want to default to.  Then you'll never have to worry about it again.  If they tell you that you can't have it that way, then tell them to give you a FULL copy of the existing .ini file that is in use where you can access it and make the change(s) you need.  Be careful though!

Link to comment
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.