I am trying to print a date and time stored in a DB.
Here is my code
print date("d-m-y H:i",strtotime($created));
This shows the date as 01-01-70 01:00
however the date in the DB is 2013-10-04 14:18:17
Can anyone help?
you sure about that ? i test it and got worked :
date("d-m-y H:i",strtotime('2013-10-04 14:18:17')); // output : 04-10-13 14:18
Store it in the database in the format yyyy-mm-dd and the when you retrieve it from the database use
$date = the date data from the database;
$date = date_parse($date);
echo $date['day'].'-'.$date['month'].'-'.$date['year'];
You can even take the date in dd-mm-yyyy then just change to the database format before inserting.
example:
$date = date($_POST['year'].'-'. $_POST['month'].'-'.$_POST['day']);