Sir I have these codes

<?php
$stockdate="";

$queryx = "SELECT max(data.date)as date
from (
select max(date)as date  from crprp  
union all
select max(date)as date from pouring  
union all
select max(date)as date from product  
) as data";

$resultx = sqlsrv_query($con,$queryx)or die ("Error". sqlsrv_errors($con)) ;  
while ($rowx = sqlsrv_fetch_array ($resultx)){
$stockdate=($rowx['date']);
}
print_r($stockdate);

echo date('l F d, Y', strtotime($stockdate));
?>

The codes displays this result
Untitled2.png

I tested the codes at some place like this
Untitled.png

The result is ok here but what is worng with my above codes?

Please

Hi,

from the documentation the strtotime() function you can read:

Parse about any English textual datetime description into a Unix timestamp

And it expects:

int strtotime ( string $time [, int $now = time() ] )

The $stockdate is a DateTime object, not a string. So try by submitting the string:

date('l F d, Y', strtotime($stockdate->date));

Or follow the DateTime library:

print $stockdate->format('l F d, Y');

Docs:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.