473,587 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
Jul 17 '05 #1
3 3320
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
I noticed that Message-ID: <4Igpc.26291$5a .24525@okepread 03> 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
>> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
11896
by: Albert Ahtenberg | last post by:
Hi, I have a database with a date field. And I would like to see the report grouped by a ceratin month and year, how can I do that without multiple queries? Albert Ahtenberg
2
3184
by: Yulia Yegenov | last post by:
I have a query that looks like this: (I insert the date created with the php date function) $status = "Active"; //(I cannot use the mysql timestamp function for other reason). $curdate = date("m/j/Y H:i"); $owner = "not assigned"; @ $db_connect = mysql_connect("localhost", "$db_username", "$db_password");
10
8035
by: Bob Bedford | last post by:
I've two input fields in wich the user enter dates. I've put something like "enter date here (dd/mm/yyyy) but most of the user don't enter date in correct format. So I'd like to be able to get any format coming from user as I must put those dates in a MySQL database: some format: (non-US format, so day/month/year) 1/9/2004 1/09/2004 01/9/2004
4
3319
by: Dan Lewis | last post by:
I've imported a ms access database into a table in a mysql database. The access database contains a field that holds date/time values in 'general date' format. These all show up at 01/01/1970 in the mysql database. I believe the field in mysql is wanting UTC and shows numbers when looked at from the sql command line (i.e. March 13, 2006, 5:31 pm is shown as 1142289086). How do I get the access data into that format so it will import...
2
6147
by: hph | last post by:
Please be gentle; I am a relative newbie for php/MySQL, and most of what I am doing is based on being self-taught using someone else's well-written code, and my own googling the answers to my questions. I'm doing a php/MySQL page that reads data out of a MySQL database. Longer term, I'll do a data-entry screen allowing me to modify the database or add new records. For now, I'm just using phpmyadmin to data enter stuff. Is there a way...
11
21063
by: walterbyrd | last post by:
My MySQL table has a field that is set as type "date." I need to get today's date, and insert it into that field. The default for that MySQL field is 2006-00-00. I know about the date() function. I have tried date("Y-m-d") and date("U"), neither worked. The date field was just filed with all zeros. Can anybody point me in the right direction?
8
5372
by: libsfan01 | last post by:
how can i use regular expressions to ensure a mysql format date entry in a text field? thanks marc
6
3932
by: Geoff Cox | last post by:
Hello, at the moment I can add the combined date and time into MySQL using php $dt1 = date("Y-m-d H:i:s"); is it possible to add the date and time separately? I thought it might be
8
3054
by: Tony B | last post by:
I have a string in a existing php script which is in the form "dd/mm/yyyy" and I need to convert it into a suitable format for mysql which is "yyyy-mm-dd" Is there a neat way of doing this in php ?
0
7923
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5719
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.