I have a database with a table, and it has a field with datetime type. When I collect data from that field and show it in PHP, it shows “Oct 9 2012 2:06PM”. I want to convert its format to “10/09/2012 14:06:00”. Please note that before I convert it, it doesn’t have “second” and I want it have “00” seconds after conversion.
How can I format this date in PHP?
You should familiarize yourself with PHP’s
date()function.A similar date format could be created with:
The
strtotime()call on the date from the database will be required first in-order to convert the date into a Unix timestamp which can then be passed to thedate()function (for formatting).