Jump to content

Paul-D

Members
  • Content Count

    23
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Paul-D

  • Rank
    Member
  1. Paul-D

    subtract a month from a date()

    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?
  2. Paul-D

    subtract a month from a date()

    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; ?>
  3. Paul-D

    subtract a month from a date()

    would CURDATE() + INTERVAL 5 DAY take me back to the first of the previous month. In this case 1st December 2018 ? ? ? ? ?
  4. Paul-D

    subtract a month from a date()

    $get_date->modify('-30 days'); I could just as well do $date = time() $diff = 60*60*24*30; $date = $date - $diff; However if it was the 31st of the month this would not take me to the previous month.
  5. Paul-D

    subtract a month from a date()

    I have created a php.ini file and added it to the website root contents [Date] date.timezone=Europe/London
  6. Paul-D

    subtract a month from a date()

    I have never used a php.ini file and don't know how it is implemented. Can I not use $date = new DateTime('first day of last month', "Europe/London"); or do I just create a file php.ini in the www root of my website with the lines [Date] date.timezone=Europe/London
  7. Paul-D

    subtract a month from a date()

    Using your code supplied I get Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.' in /vhost/vhost15/d/e/s/desmond-otoole.co.uk/www/class.php:6 Stack trace: #0 /vhost/vhost15/d/e/s/desmond-otoole.co.uk/www/class.php(6): DateTime->__construct('first day of la...') #1 {main} thrown in /vhost/vhost15/d/e/s/desmond-otoole.co.uk/www/class.php on line 6
  8. Paul-D

    subtract a month from a date()

    its not my php. I RENT web space from a company Easy Space (UK). I don't have direct access to their server only to upload and download to my space and I also have a MySql database.. If there are any questions I should ask them then please tell me. TIA Desmond.
  9. Paul-D

    subtract a month from a date()

    <?php echo PHP_VERSION; error_reporting(E_ALL); ini_set('display_errors', 1); echo phpinfo(); //$date = new DateTime('first day of last month'); //echo $date; ?>
  10. Paul-D

    subtract a month from a date()

    Fatal error: Call to undefined function phpinfo()
  11. Paul-D

    subtract a month from a date()

    I am used to C++ and visual C++ There you have to include a class structure into the code.
  12. Paul-D

    subtract a month from a date()

    <?php echo PHP_VERSION; error_reporting(E_ALL); ini_set('display_errors', 1); $date = new DateTime('first day of last month'); echo $date; ?>
  13. Paul-D

    subtract a month from a date()

    echo PHP_VERSION; = 5.4.45
  14. Paul-D

    subtract a month from a date()

    The problem with this is, it is a PHP website I have created. So <?php $date = new DateTime('first day of last month'); echo $date; ?> doesn't work. I subscribe to a website company easyspace. Do I need to do anything to create the DateTime class?
  15. Hi if i have $date = "12-08-2018" or "2018-08-12" Need to subtract a month. Could this be done for day and year even? TIA Desmond. P.S. What I want to do is clear out a database table with records over a month old so today is 27th Jan 2018. I would like to create a date “2018-12-01” I can then use this in an SQL to delete all before “2018-12-01”
×

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.