-1

I like to convert a date format dd/mm/yyyy to another format in PHP.

My Code:

$date = '29/01/2018';
echo date('l jS F Y', strtotime($date)); 

When I run the above code, it's showing me some wrong date:

Thursday 1st January 1970

Am I doing anything wrong?

Glavić
  • 42,781
  • 13
  • 77
  • 107

2 Answers2

2

You could also use the DateTime objects to help you converting dates. You can "create a datetime object from an specified format" and convert it.

$date = "29/01/2018";
$dt = DateTime::createFromFormat("d/m/Y", $date);

echo $dt->format("l jS F Y");
Felipe G.
  • 154
  • 1
  • 9
0

signifies American M/D/Y formatting

<?php

$date = '01/29/2018';
echo date('l jS F Y', strtotime($date)); 

output

Monday 29th January 2018
Ganesh Kandu
  • 601
  • 5
  • 15