0

I got in my table two types:

hour_Event in type date
date_Event in type datetime

I would like hour_Event to be formatted to hh:mm and date_Event to be dd/mm/yyyy

I use PHPMyAdmin and im new with MySQL so I dont know how to change the format and for what.

How do I do it?

KingBob
  • 792
  • 2
  • 6
  • 14

2 Answers2

0

You could change the format using php before you insert data or after retrieving themfrom your database according to your needs.You could use DateTime / strtotime() & date(). In most cases a single timestamp field in your table is enough for an event.

Have a look here:

Convert one date format into another in PHP

Also you could format your field according to your needs with mysql for example:

DATE_FORMAT(tables.field, '%d-%m-%Y %H:%i:%s') AS 'new_name'

Have a look about it here:

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format

Community
  • 1
  • 1
0x_Anakin
  • 3,229
  • 5
  • 47
  • 86
0
**DATE_FORMAT(hour_Event,'%h:%i')** will give you hour_Event in hh:mm 

and

**DATE_FORMAT(date_Event,'%d/%m/%Y')** will give you date_Event in dd/mm/yyyy
murtaza.webdev
  • 3,523
  • 4
  • 22
  • 32
  • where do I use it? is this somehthing that I exceute every time I insert something or I edit the filed propeties? – user2502867 Jan 11 '14 at 11:22