dates when saving to mysql database
Posted
by Patrick
on Stack Overflow
See other posts from Stack Overflow
or by Patrick
Published on 2010-04-14T20:45:04Z
Indexed on
2010/04/14
20:53 UTC
Read the original article
Hit count: 168
mysql
in my php code I was asking the user to choose day, month and year from some dropdown fields where values where 1, 2, 3 etc instead of 01, 02, 03.
these were then combined to form a string like "YYYY-MM-DD" for the insertion in a db (in a date field).
Having missed the initial 0, I thought I was sending strings in the wrong format, eg "YYYY-M-D" or YYYY-MM-D", but then I've noticed they appear in the right format in the database anyway: even if I submitted YYYY-M-D, it appeared as YYYY-MM-DD.
is this the normal behaviour of mysql? if so, can i just avoid worrying about changing the code in my application?
© Stack Overflow or respective owner