Hi Bruce,

Try looking at php's date function
(http://www.php.net/manual/en/function.date.php).  That function allows
you to format a date variable however you need it to.  And to convert
mySQL's returned string into a date php can use, try the strtotime
function (http://www.php.net/manual/en/function.strtotime.php).

Mark

-----Original Message-----
From: Roman Neuhauser [mailto:[EMAIL PROTECTED] 
Sent: Sunday, March 30, 2003 9:28 AM
To: Bruce Feist
Cc: MySQL List
Subject: Re: MySql, PHP, and Dates

# [EMAIL PROTECTED] / 2003-03-28 21:47:28 -0500:
> 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).

    PHP returns all values from MySQL as strings; IOW, if you have an
    int column, fetching -10 from it will yield "-10".

    The reason you get the datetime in the format you get has nothing to
    do with PHP. Check the MySQL manual.

    BTW, there's no such thing as "PHP date".

-- 
If you cc me or remove the list(s) completely I'll most likely ignore
your message.    see http://www.eyrie.org./~eagle/faqs/questions.html

-- 
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]

Reply via email to