having problem in insering date in mysql database On inserting date in table date is being displayed as 0000-00-00

$content = file_get_contents("http://api.themoviedb.org/3/movie/$id?api_key=c1259239b41c48480d727f85c677fbf6");

$moviedetailsArray = json_decode($content,true);

$budget = $moviedetailsArray['budget'];
$rlsdate = $moviedetailsArray['release_date'];

$query = "UPDATE `latestmoviesdetails` SET `budget` = $budget,`releasedate` = $rlsdate WHERE movieid = $id";

mysqli_query($link,$query);
Is this Perl code?

I think the problem is that SQL doesn't recognize the date format. Just before doing the query, insert a print statement to see what exactly is in $rlsdate.

MySQL expects date in this format: '2019-03-13 16:35:42'

If your date is in unix timestamp format, you can use FROM_UNIXTIME() in your query:

$query = "UPDATE `latestmoviesdetails` SET `budget` = $budget,
                 `releasedate` = FROM_UNIXTIME($rlsdate)
          WHERE movieid = $id";


If it's in a date format that is not YYYY-MM-DD, use STR_TO_DATE() function. Example:

mysql&gt; SELECT STR_TO_DATE('01,5,2013','%d,%m,%Y');
        -&gt; '2013-05-01'
mysql&gt; SELECT STR_TO_DATE('May 1, 2013','%M %d,%Y');
        -&gt; '2013-05-01'
mysql&gt; SELECT STR_TO_DATE('04/31/2004', '%m/%d/%Y');
        -&gt; '2004-04-31'