473,382 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

text input of date and timestamp fields

I'm working on a PHP frontend for a PostgreSQL db and I'm looking for the
best way to create date or timestamp inputs. Let's take a date in the
format yyyy-mm-dd as an example. This is too error prone, I know my users
will do it wrong

<input type="text" name="fieldname">

Right now I'm thinking about something like this:

<input type="text" size="4" name="y_fieldname">-
<input type="text" size="2" name="m_fieldname">-
<input type="text" size="2" name="d_fieldname">

but this is IMO a very ugly solution, because after the SUBMIT I have to
glue all the parts together before inserting the values into the db.
Something like this:

<input type="text" format="yyyy-mm-dd" name="fieldname">

would be ideal, but AFAIK this doesn't exist in HTML. Can anybody give me
any tips? How did you solve this? Thanks!
Jul 17 '05 #1
2 8847


I'm working on a PHP frontend for a PostgreSQL db and I'm looking for the
best way to create date or timestamp inputs. Let's take a date in the
format yyyy-mm-dd as an example. This is too error prone, I know my users
will do it wrong

<input type="text" name="fieldname">

Right now I'm thinking about something like this:

<input type="text" size="4" name="y_fieldname">-
<input type="text" size="2" name="m_fieldname">-
<input type="text" size="2" name="d_fieldname">

but this is IMO a very ugly solution, because after the SUBMIT I have to
glue all the parts together before inserting the values into the db.
Something like this:

<input type="text" format="yyyy-mm-dd" name="fieldname">

would be ideal, but AFAIK this doesn't exist in HTML. Can anybody give me
any tips? How did you solve this? Thanks!


I have run up against the same problem, as there is indeed no way to do
this in HTML.

I've used three boxes, with gluing together, but used a select drop-down
box instead of month, so there's then no question of which is the day and
which is the month.

I've also added a configurable option for year which allows users to enter
two-figure dates instead of four (i.e. the interface accepts either and
converts the actual database input accordingly, by appending 19 or 20
depending on the set year cut-off point.
Martin Lucas-Smith www.geog.cam.ac.uk/~mvl22
www.lucas-smith.co.uk
Jul 17 '05 #2
On Thu, 23 Oct 2003 17:34:43 +0100, Martin Lucas-Smith wrote:
I have run up against the same problem, as there is indeed no way to do
this in HTML.

I've used three boxes, with gluing together, but used a select drop-down
box instead of month, so there's then no question of which is the day
and which is the month.

I've also added a configurable option for year which allows users to
enter two-figure dates instead of four (i.e. the interface accepts
either and converts the actual database input accordingly, by appending
19 or 20 depending on the set year cut-off point.


Thanks Martin. Well, I guess it's time to create some real ugly code :-)

The naming of the fields is the ugliest part of it. The fieldnames in the
frontend are dynamic (fields from a postgresql db), so I guess I will have
to do naming like this

fld_d_y_birthday
fld_d_m_birthday
fld_d_d_birthday

fld_t_y_takeoff
fld_t_m_takeoff
fld_t_d_takeoff
fld_t_h_takeoff
fld_t_M_takeoff
fld_t_s_takeoff

and my backend will have to parse the $_POST array twice. The first time
to make whole values of the fld_d_* and fld_t_* elements. And a second
time to create the SQL INSERT statement.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
2
by: David Garamond | last post by:
When a timestamp string input contains a timezone abbreviation (CDT, PST, etc), which timezone offset is used? The input date's or today date's? The result on my computer suggests the latter. #...
4
by: DeanL | last post by:
Hi everyone, Does anyone know of a way in MS Access to have the ControlTip Text that can be set with a message to pop up with the date/time that the field on the form was last updated along with...
2
by: jrthor2 | last post by:
I have a shell script that I am using the db2 load command to populate my table with. I have a problem with the dates though. In my file that I am populating the table with, I have 3 date fields...
10
by: satishrajana | last post by:
Hi, My SQL returns a NULL in a datefield if there is no date in that field. If there is a NULL in this column, I want to replace it with spaces in my SELECT statement when I am selecting these...
4
by: mtuller | last post by:
I have a database that stores time in 2 different formats. I have a unix timestamp, and the other is a representation of time in the format 03:00:00 which would represent 3 hrs. I want to convert...
1
by: Arli | last post by:
I have the following linked tables: tblMainPL is my main table that I need to pull the information in from. It has the following fields: Autonumber1 -PK set as autonumber Date - short date...
7
by: kirkgilbert | last post by:
I am trying to do an onchange event in a form using a text field. The form is tied to a record set that is part of a repeated region. One the first record when I edit the data it works perfectly. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.