I am writing a php application which is using a MS SQL database and I have the following code:
$nextdue = date('Y-m-j', strtotime('+'.$validity.' months', strtotime($issuedate)));
The purpose of the code is to add a number of months to a document issue date to calculate an expiry date. For the purpose of this query, the validity period looks up the document type and returns the number of valid months for that particular document - I know this is working. I have used this code before for a PHP and MySQL database and it worked just fine. I am assuming I have missed something in the way MS SQL stores date format?
When I have an issue date of 19/05/2022 (dd/mm/yyyy), it is adding 36 months to it and then returning a value of 01/01/1979 - which is clearly wrong.
Can anyone help me out please?
Also I have done a var_dump for issue date which returns as
IssueDate:19 \ / 05 \ / 2022