0

Somebody please help me to format the date. I'm not familiar with date formatting. I want to increment the date by one month but i get this error:

"A non well formed numeric value encountered"

$bseDate=$_POST['lastBseDate']; //this will return 2014-04-03
$nextBse = date('y-m-d', strtotime("+1 month", $bsedate));
spencer7593
  • 106,611
  • 15
  • 112
  • 140
imfarihah
  • 3
  • 3
  • possible duplicate of [A non well formed numeric value encountered](http://stackoverflow.com/questions/6136430/a-non-well-formed-numeric-value-encountered) – αƞjiβ Apr 29 '15 at 17:57

2 Answers2

2

Use Datetime() for all date manipulation as it takes Daylight Savings Time and more into consideration and is more readable and maintainable.

$nextBse = (new DateTime($_POST['lastBseDate']))->modify('+1 month')->format('y-m-d');
John Conde
  • 217,595
  • 99
  • 455
  • 496
1

To answer your question, strtotime gives a timestamp from a string, but since you are providing the optional base time it needs to be a timestamp as well:

$nextBse = date('y-m-d', strtotime("+1 month", strtotime($bseDate)));
AbraCadaver
  • 78,200
  • 7
  • 66
  • 87