tibberous Posted August 12, 2008 Share Posted August 12, 2008 Is this right? $data['birthDate'] = $birthDate ? date("Y-m-d", $birthDate) : ''; To store in a mysql database, where $birthDate is a timestamp? Link to comment https://forums.phpfreaks.com/topic/119251-how-is-mysqls-date-format-y-m-d/ Share on other sites More sharing options...
GingerRobot Posted August 12, 2008 Share Posted August 12, 2008 I think your ternary operator is a bit confused. There's no condition being evaluated. Unless you meant to compare $data['birthDate'] to $birthDate? In which case, that assignment operator (=) needs to be an equality comparison operator (==), and you need to be assigning the value to a variable (or echoing it, etc). But yes, if your field is a date field, the format is YYYY-MM-DD, so will be generated by date('Y-m-d'). Link to comment https://forums.phpfreaks.com/topic/119251-how-is-mysqls-date-format-y-m-d/#findComment-614300 Share on other sites More sharing options...
tibberous Posted August 15, 2008 Author Share Posted August 15, 2008 Yes their is, it's (boolean)$birthDate. I'm using to see if they put in a birthdate, and leaving it blank if they haven't. Link to comment https://forums.phpfreaks.com/topic/119251-how-is-mysqls-date-format-y-m-d/#findComment-617141 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.