1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Php date error help

Discussion in 'PHP' started by fadetoblack22, Jan 14, 2019 at 3:13 AM.

  1. #1
    I'm getting this for my site and it's not loading:
    SEMrush
    PHP Fatal error: Cannot redeclare date_add() in /home/footyall/public_html/include/functions.php on line 1882

    Any ideas of how to fix it?
     
    Solved! View solution.
    fadetoblack22, Jan 14, 2019 at 3:13 AM IP
    SEMrush
  2. Fiverscripts

    Fiverscripts Moderator Staff

    Messages:
    1,830
    Likes Received:
    41
    Best Answers:
    1
    Trophy Points:
    370
    Digital Goods:
    9
    #2
    as the error says.. the is already a built-in function named date_add you can redeclare it / replace with yours.. would help if you shared the code but thats exactly as its telling you..

    Added info for the function: http://php.net/manual/en/function.date-add.php
     
    Fiverscripts, Jan 14, 2019 at 5:09 AM IP
  3. fadetoblack22

    fadetoblack22 Well-Known Member

    Messages:
    2,322
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    160
    #3
    fadetoblack22, Jan 14, 2019 at 5:38 AM IP
  4. Fiverscripts

    Fiverscripts Moderator Staff

    Messages:
    1,830
    Likes Received:
    41
    Best Answers:
    1
    Trophy Points:
    370
    Digital Goods:
    9
    #4
    Rename this function:

    function date_add($timestamp, $months)
    {
       $d       = getdate ($timestamp);
       $mon     = $months % 12;
       $years   = $months / 12;
       $mytime  = mktime ($d['hours'], $d['minutes'], $d['seconds'], $d['mon'] + $mon, 1, $d['year'] + $years);
       $days    = min ($d['mday'], date ('t', $mytime));
       $mytime += ($days -1) * 86400;
       return $mytime;
    }
    Code (markup):
    rename: date_add bit..

    Note you will need to find everywhere you are actually using this and also change it.. i.e if you are calling that function elsewhere you need to rename it the same..

    thanks
     
    Fiverscripts, Jan 14, 2019 at 5:57 AM IP
  5. fadetoblack22

    fadetoblack22 Well-Known Member

    Messages:
    2,322
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    160
    #5
    Sorry, I don't understand. What would I rename it to?
     
    fadetoblack22, Jan 14, 2019 at 6:33 AM IP
  6. Fiverscripts

    Fiverscripts Moderator Staff

    Messages:
    1,830
    Likes Received:
    41
    Best Answers:
    1
    Trophy Points:
    370
    Digital Goods:
    9
    #6
    e.g
    function mydate_addfunction($timestamp, $months)
     
    Fiverscripts, Jan 14, 2019 at 7:55 AM IP
  7. fadetoblack22

    fadetoblack22 Well-Known Member

    Messages:
    2,322
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    160
    #7
    Thanks, so just anything?

    What I don't get is why the previous one stopped working. Is there a reason why?
     
    fadetoblack22, Jan 14, 2019 at 8:10 AM IP
  8. #8
    yeah.. as i mentioned earlier

    "Added info for the function: http://php.net/manual/en/function.date-add.php"

    the is already a built in function called it as above.. thats why

    Note: feel free to push "best answer" if you found my replies helpful :)
     
    Fiverscripts, Jan 14, 2019 at 8:14 AM IP
  9. fadetoblack22

    fadetoblack22 Well-Known Member

    Messages:
    2,322
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    160
    #9

    Let me try and understand...php has an added function now which is conflicting with it. Is that right?
     
    fadetoblack22, Jan 14, 2019 at 8:17 AM IP
  10. Fiverscripts

    Fiverscripts Moderator Staff

    Messages:
    1,830
    Likes Received:
    41
    Best Answers:
    1
    Trophy Points:
    370
    Digital Goods:
    9
    #10
    i actually think this function has been around for a while did your server possibly update php versions recently?
     
    Fiverscripts, Jan 14, 2019 at 8:18 AM IP
  11. fadetoblack22

    fadetoblack22 Well-Known Member

    Messages:
    2,322
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    160
    #11
    Yeah, the site was offline for a while and I re-uploaded it.

    Any idea how I can search for all instances of the function?
     
    fadetoblack22, Jan 14, 2019 at 8:33 AM IP
  12. Fiverscripts

    Fiverscripts Moderator Staff

    Messages:
    1,830
    Likes Received:
    41
    Best Answers:
    1
    Trophy Points:
    370
    Digital Goods:
    9
    #12
    i would use agent ransack (google it.. freeware for none commercial use) search for instances containing that specific function
     
    Fiverscripts, Jan 14, 2019 at 8:48 AM IP
    fadetoblack22 likes this.
  13. fadetoblack22

    fadetoblack22 Well-Known Member

    Messages:
    2,322
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    160
    #13
    Thank you!
     
    fadetoblack22, Jan 15, 2019 at 1:41 AM IP
    Fiverscripts likes this.
  14. Alice Egger

    Alice Egger Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #14
    Hi,
    You can use date("Y/M/D") function. I works.
     
    Alice Egger, Jan 18, 2019 at 2:42 AM IP
  15. fadetoblack22

    fadetoblack22 Well-Known Member

    Messages:
    2,322
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    160
    #15
    Do you mean instead of DMY?
     
    fadetoblack22, Jan 18, 2019 at 3:54 AM IP