djanim8 Posted June 11, 2008 Share Posted June 11, 2008 I think the host of a website I work on upgraded to PHP 5.2.6 without telling us (BAD!)... which has caused some random problems.. most of which are fixed, but this one I can't figure out for the life of me... I have this line of code: date('Y-m-d', strtotime("$eventDate + $totalDays days")) the $eventDate is a date in yyyy-mm-dd format that is pulled from a database (echoed this, it is correct). the $totalDays is negative number also pulled from a database (-14 is the value now).. I've echoed this and it works fine. and this statment above ALWAYS returns 1969-12-31 and I can't get it to return anything else... has something changed and I can't find a solution for? this has worked for over a year!! Link to comment https://forums.phpfreaks.com/topic/109677-problem-with-date-or-strtotime/ Share on other sites More sharing options...
kenrbnsn Posted June 11, 2008 Share Posted June 11, 2008 Get rid of the "+" sign. Just use: <?php date('Y-m-d', strtotime("$eventDate $totalDays days")) ?> My quick tests show that the above works for both positive and negative numbers. Ken Link to comment https://forums.phpfreaks.com/topic/109677-problem-with-date-or-strtotime/#findComment-562781 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.