Calculate Future or Past date in Java, PHP

This tutorial will show you how can you calculate either future date from a particular date to “plus a number of given days” or past date from a particular date to “minus a number of given days”.

I will show you this calculation both in Java and PHP language.

In PHP

We first need to setup an appropriate timezone otherwise php sometimes give warnings. I have set “Asia/Kolkata”, you can set according to your timezone.

Output

In Java

The below source code shows how we can calculate future or past date in Java.

Output

That’s all. Thanks for your reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.