Hi Bruce, I gather that PHP can treat any data as a string and will do by default, unless you try and do something to the data that suggests it is not a string. ie, you can return a result '23' from a database and find the first character of it, as if it were a string, but you can also then add it to another number, as if it were an integer - PHP is very accomodating in this way.
Dates can be formatted by the DATE_FORMAT command in MySQL. Alternatively, you can use the UNIX_TIMESTAMP function to return the date as a timestamp and then use the PHP function date() to take in the timestamp and return a date in any format you please. Peter. -----Original Message----- From: Bruce Feist [mailto:[EMAIL PROTECTED] Sent: Saturday, 29 March 2003 1:17 PM To: MySQL List Subject: MySql, PHP, and Dates I'm experienced with SQL, but new to MySql and PHP, which I'm using together to create a dynamic web site. Right now, I'm having minor difficulties with date formatting. It seems that when I retrieve a date from MySQL into PHP, it shows up as a string instead of a date data type, with format YYYY-MM-DD HH:MM:SS. Is there any way that I can get it returned as a PHP date instead? Also, exactly what is it that controls the output format of the date as a string? Is PHP somehow requesting that MySql return the date as a string, or is it getting a date from MySql and then converting it to a string on the PHP side? What's the best way of controlling date format? Obviously, I could use string operators to extract the year, month, and day and do whatever I want to with them, but that's sensitive to how PHP and/or MySql are configured, I assume; it would be better for me to request the date in a specific form (ideally one taken from operating system preferences). Thanks! Bruce Feist -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]