By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,805 Members | 1,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,805 IT Pros & Developers. It's quick & easy.

String to mysql date field

P: n/a
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.
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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/
Jul 17 '05 #2

P: n/a
I noticed that Message-ID: <4Igpc.26291$5a.24525@okepread03> from Jeff
Rodriguez contained the following:
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.


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/
Jul 17 '05 #3

P: n/a
>> 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.


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
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.