Hello,

I am trying to record a birthdate. I am looking for the right variable to do that.

The only option in mysql database xampp is datetime: yyyy-mm-dd hh:mm:ss

While I would like it to be: dd-mm-yyyy ?

How? If I input the data dd-mm-yyyy will my database adapt to it?

Member Avatar for diafol

Always store in yyyy-mm-dd (Y-m-d) as this is then sortable. Not so with other formats, unless using something like unix timestamps. You can change the format to your liking in your SELECT queries:

DATE_FORMAT(date, format)

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

For input odd formats to Y-m-d use:

STR_TO_DATE(str, format)

http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.