I have a database that stores the time for me. I insert it from PHP using
date( \'Y-m-d H:i:s\');
I then use this function to convert it t
You can use the strtotime
and date
function:
echo date('Ymdhis', strtotime($date));
here you go
print date("YmdHis",unixtimestamp);
Use date.
$date = date("YmdHis", $timestamp);
Use the right format :
date('YmdHis');
If you're using mysql, it has a DATE_FORMAT
function. You can call it like
SELECT DATE_FORMAT(`datefield`, "%Y%m%d%H%i%s") AS `date_formatted` FROM table;
So you get an already formatted date from your database.