-1

I am trying find the next date.Suppose today is 23-07-2019 and i want to echo 24-07-2019 but i can't. I execute the below code and it gives me some error. they give this error :

Notice: A non well formed numeric value encountered in C:\xampp\htdocs\telehealth\twilio_Sms\autometic.php on line 2 24

Now please anyone help what is my mistake and what should i change to correct this. I am trying many thins but i could not solve it

echo (date('d-m-Y')+"1");
suhas pandit
  • 273
  • 2
  • 16
Foisal Hossain
  • 129
  • 1
  • 8

1 Answers1

0

The trouble is that the date('d-m-Y') returns string with - symbols and you try to sum it with a "1". You can't mix php types in this way.

First of all you definitely should read about php types, php math operations and type juggling.

Next, there is a special library to work with date and time. And you definitely should use it to date and time operations. The DateTime is an object that contents date and time and can be represented as string by format function.

Operations with date and time are quite difficult (leap years, February and so son). And it is highly recommended to use special API from DateTime.

So, for you task (refer to add function of datetime):

$date = new \DateTime('23-07-2019');
$date->add(new \DateInterval('P1D'));
echo $date->format('Y-m-d);
marv255
  • 808
  • 6
  • 19