Re: php mysql dates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 28 Jul 2004 14:39:01 -0700, Irm Jr <irmjr@xxxxxxxx> wrote:
> Sure I understand Y-m-d.  But won't the database cry because the Month
> is in text format? (January, february....)?  Thanks again.
> 

Whoops, I should read *all* the text of the question...

Easiest way to deal with that, IMHO, is strtotime and date.

$mysqlDate = date('Y-m-d', strtotime($month.' '.$day.', '.$year));

If you're using dates far in the past or future, though, this won't
work. Better to use a date handling class, such as:

http://pear.php.net/package/Date

> Subject: Re:  php mysql dates
> 
> 
> 
> On Wed, 28 Jul 2004 14:30:24 -0700, Irm Jr <irmjr@xxxxxxxx> wrote:
> >
> > Hi all, currently I have a form which prompts for the user to choose a
> 
> > date.  The dropdown lists are stored into variables:
> >
> > $month        //e.g. January, February, ...
> > $day           //e.g 1 - 31
> > $year          //e.g. 2004 (four digits)
> >
> > then combined into
> >
> > $articleDate
> >
> > How can I manipulate this variable to be in such a format that I can
> > insert the information into a DATE column in a mySQL database.
> >
> > Dates are a bit of a mystery to me as PHP and MySQL handle them
> > differently.  Your help is appreciated.
> >
> 
> Y-m-d
> 
> --
> DB_DataObject_FormBuilder - The database at your fingertips
> http://pear.php.net/package/DB_DataObject_FormBuilder
> 
> paperCrane --Justin Patrin--
> 

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux