Home > Archive > PHP Language > May 2004 > String to mysql date field
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
String to mysql date field
|
|
|
| How do I convert a string into a value I can upload to mysql date field.
Specifically, I have a user select a month, day and year from
drop-downs, then I want them submitted to one date field. Thanks!
Steve.
| |
| Jeff Rodriguez 2004-05-15, 1:30 am |
| Noyb wrote:
> How do I convert a string into a value I can upload to mysql date field.
> Specifically, I have a user select a month, day and year from
> drop-downs, then I want them submitted to one date field. Thanks!
> Steve.
You want to convert a string to a unix timestamp, then you can use the functions
in mysql to convert the timestamp to mysql native.
http://www.php.net/manual/en/function.strtotime.php
Also, use Mishoo's dHTML calendar: http://sourceforge.net/projects/jscalendar/
| |
| Geoff Berrow 2004-05-15, 6:30 am |
| I noticed that Message-ID: <4Igpc.26291$5a.24525@okepread03> from Jeff
Rodriguez contained the following:
>
>You want to convert a string to a unix timestamp, then you can use the functions
>in mysql to convert the timestamp to mysql native.
Why, when he can arrange the dropdown boxes to provide a suitable date?
Say the boxes return year month and day
function make_mysql_date($y,$m,$d){
$array = array($y,$m,$d);
$mysql_date = implode("/", $array);
return $mysql_date;
}
Not that I usually bother with MySql's date format these days. Mostly I
simply store a Unix timestamp.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
| |
| Gordon Burditt 2004-05-16, 7:30 pm |
| >> How do I convert a string into a value I can upload to mysql date field.
>
>You want to convert a string to a unix timestamp, then you can use the
>functions
>in mysql to convert the timestamp to mysql native.
This doesn't work very well for some applications. It's problematical
for anything dealing with a date of birth of a living person, and
even more problematical for genealogy. (Some implementation treat
a UNIX time_t as signed, yielding a time range of about 1901-2038,
which is too small. Even worse is the ones that interpret it as
unsigned, giving a time range of about 1970-2106, which is really
bad if your application deals with people receiving retirement
benefits).
Even the MySQL native date format has problems if you can trace
your ancestors back more than about 2,004 years.
Gordon L. Burditt
|
|
|
|
|