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
  • 103,596
  • 14
  • 107
  • 133
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
  • 212,985
  • 98
  • 444
  • 485
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
  • 77,023
  • 7
  • 60
  • 83