0

I have a string in an array which is like so

19/08/2015 12:08

I access this string using

$row["CREATE_DATE"]

If I do the following

var_dump($row["CREATE_DATE"] . "<br>");
var_dump(date("Ymd", strtotime($row["CREATE_DATE"])));

I get the output

string(20) "19/08/2015 12:08"
string(8) "19700101" 

Why does the strtotime do my date as 1970?

Thanks

katie hudson
  • 2,765
  • 13
  • 50
  • 93

2 Answers2

3

You are doing it in wrong way.Use this :

var_dump(date("Ymd", strtotime(str_replace("/","-",$row["CREATE_DATE"]))));

See this link for all the supported date formats

sanderbee
  • 694
  • 7
  • 24
Happy Coding
  • 2,517
  • 1
  • 13
  • 24
0
<?
$row["CREATE_DATE"]="19/08/2015 12:08";
echo $d=date("Y-m-d", strtotime($row["CREATE_DATE"])); => 1970-01-01

But, When changing the format $row["CREATE_DATE"]="19-08-2015 12:08";
echo $d=date("Y-m-d", strtotime($row["CREATE_DATE"])); => 2015-08-19

So, What @RaveenaNigam Said, We Have To Use This Way.
var_dump(date("Ymd", strtotime(str_replace("/","-",$row["CREATE_DATE"]))));
=> 2015-08-19
?>
Nana Partykar
  • 10,556
  • 10
  • 48
  • 77