Calculate date using PHP


I am currently using the following PHP string which collects the due date from an invoice in the format DD.MM.YYYY.

<?php echo date_from_mysql($invoice->invoice_date_due , TRUE); ?>

I would like to automatically calculate the date five days prior to this, and if possible, have it display in full (eg. Monday, 1st January 2016)

Any help on this would be appreciated!




Try this for your required date formation

 $date = new DateTime('01.02.2016');  //modify if you wish
 $date->sub(new DateInterval('P5D')); //calculate the date five days prior 
 echo $date->format('l, jS F Y') . "\n"; //formatted as you mentioned

People are also looking for solutions to the problem: php - How to tell what Version of MongoDB you are Running


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.