0

I used Bootstrap datepicker to get date from the user. I stored that value in database. But when i render this date in html, it showed unexpected value with the date !

I give the screen shot of the result.

enter image description here

Can anyone help me to solve this ?

  • 1
    Perhaps an earlier question will help? http://stackoverflow.com/questions/1056728/where-can-i-find-documentation-on-formatting-a-date-in-javascript – Lance Leonard Jan 03 '15 at 16:51

1 Answers1

1

How have you stored the date in the database?

Make sure you used DATETIME and not VARCHAR

Also how did you get the date from the database?

I would use:

$query = "SELECT DATE_FORMAT(ColumnName, '%Y-%m-%d %H:%i:%s') AS Date FROM Table";
$result = mysqli_query($cxn,$query) or die(mysqli_error());
$date = $result->fetch_object()->Date;
Mramaa
  • 400
  • 2
  • 13