-2

I have the following date: 2010-04-19 .

I would like to convert this date strtotime format and convert "Y-m" format.

Example = "2018-5"

my code:

$date1= 'onlinearticles_'.$date;
$article_table= date('Y-m',strtotime($date1));

But it didin't work, how can I do this ?

Teoman Tıngır
  • 2,766
  • 2
  • 21
  • 41

1 Answers1

1

you should add alphabetic characters later..

follow these steps;

$date = 2010-04-19;

$newDate = date("Y-m",strtotime($date));

$stringWithDate = "onlinearticles_".$newDate;

dd($stringWithDate);
Teoman Tıngır
  • 2,766
  • 2
  • 21
  • 41