2

The MySQL manual specifies the datetime to be formatted:

'2011-10-02 16:04:32'  /* YYYY-MM-DD HH:MM:SS */

But MySQL 5.1 also accepts the ISO 8601 combined date and time format:

'2011-10-02T16:04:32' /* YYYY-MM-DDTHH:MM:SS */

I often concatenate a date and time together to make a MySQL datetime datatype, and I worry the space does not look important enough in the concattenation code.

$newdate = $datepart . ' ' . $timepart;

What if someone confuses it for an empty string someday and deletes the space, breaking the application? This looks better to me:

$newdate = $datepart . 'T' . $timepart;

Will MySQL continue to support the ISO 8601 format with the 'T'?

Am I violating a best practice by doing this?

1 Answer 1

1

Will MySQL continue to support the ISO 8601 format with the 'T'?

Probably, I can't think of a reason why they would stop. There's also tons of libraries which handle timestamp parsing which would easily lend you a workaround if they randomly did stop.

Am I violating a best practice by doing this?

Not particularly, it's more of a preference than anything else.

1
  • I don't think I would need a library to add or remove a 'T'. The main point of my question is to ask if there is a best practice for MySQL. Oct 10, 2011 at 3:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.