I am receiving the error: A non well formed numeric value encountered
Here is my code:
<?php
$timestamp= '2013-01-20 18:20:20';
$datetime= date('F j, Y', $timestamp);
echo $datetime;
?>
This returns January 1, 1970 Which isn't right. What am I doing wrong? BTW: All of my $timestamp variables will be in that format. I am using datetime in my MySQL database table.
Thanks
the date
function takes a timestamp which is an int you need to call it using
date('F j, Y', time());
or
$timestamp= '2013-01-20 18:20:20';
date('F j, Y', strtotime($timestamp));
see http://php.net/manual/en/function.date.php for info on how to use the date
function
'2013-01-20 18:20:20' is not a timestamp . You have to convert it to timestamp. You can use strtotime function to do this.
$timestamp= strtotime('2013-01-20 18:20:20');