2

I am trying to change the date format in

print("<td class='month subscriber subscriber-fixed-alone fixed-cell'>$date</td>");

which prints $date as 2017-12. How would I change this to December 2017?

I have tried

print("<td class='month subscriber subscriber-fixed-alone fixed-cell'>" . date_format($date, 'F Y') . "</td>");

but I get no value. The value is pulled from an HTTP API by

foreach ($content as $dates => $row) {
$date = $dates;

Think I am missing something rather simple.

Darren
  • 2,176
  • 9
  • 42
  • 98
  • Sorry if it is. I searched for a while on this problem and didn't come across any articles that helped. – Darren Dec 21 '17 at 05:01

2 Answers2

1

try this

$originalDate = "2017-12";
$newDate = date("F Y", strtotime($originalDate));

echo $newDate;
Arun Kumaresh
  • 6,211
  • 6
  • 32
  • 50
  • Thank you. Just one question so I understand it. If the `$originalDate` value changes per request from the API. This would always show 2017-12, right? – Darren Dec 21 '17 at 05:00
  • it just a example how can you convert you date.You have to update your date value as per the api value – Arun Kumaresh Dec 21 '17 at 05:10
  • I thought so, just wondered if I hadn't understood it. Thank you again. – Darren Dec 21 '17 at 05:11
1
print("<td class='month subscriber subscriber-fixed-alone fixed-cell'>".date('F Y',strtotime($date))."</td>");
Jeffrey Hitosis
  • 325
  • 3
  • 13