473,765 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_fieldna me">-
<input type="text" size="2" name="m_fieldna me">-
<input type="text" size="2" name="d_fieldna me">

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 8862


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_fieldna me">-
<input type="text" size="2" name="m_fieldna me">-
<input type="text" size="2" name="d_fieldna me">

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_birthda y
fld_d_m_birthda y
fld_d_d_birthda y

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
43016
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 mediate between webapps and arbitrary database backends using JDBC. I am very unwilling indeed to write special-case code for particular databases. Our code has worked satisfactorily with many databases, including many instances MS SQLServer 2000...
19
6931
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 JavaScript in this code from a couple different sites but I'm not 100% sure what each line is doing...This is the ASP code that I'm using for the page....Take a look at the JavaScript code and please let me know what each line is doing....I have been...
2
4768
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. # create table ts (ts timestamptz); # insert into ts values ('2004-10-17 00:00:00 CDT'); -- UTC-5 # insert into ts values ('2004-11-17 00:00:00 CDT'); -- UTC-6 # select ts at time zone 'utc' from ts; timezone ---------------------
4
7031
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 the username of the person who updated the record? I'm using the fOSUserName() function from Dev Ashish to get the users name but I'm not sure how to get these details included in a ControlTip Text popup or if it's even possible. Hope someone...
2
4907
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 that get are in the format yyyy-mm-dd. The table has these columns set as timestamps. When my shell script runs, I get the following error: SQL3407N The beginning-ending location pair for inserting into column "35" is not valid for a...
10
39121
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 records. Can any of you experts out there help me with a sample SQL.
4
1669
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 the 3 hrs so that I can add it to the unix timestamp. In other words, The unix timestamp of 1183553400 is equal to Wed, Jul 04, 2007 7:50 AM. I want to add the 3hrs to be able to display in this format Wed, July 04, 2007 7:50 AM - 10:50 AM.
1
4272
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 format-example: (10/22/08) Load Number -Number-Single (should not be higher than 35-40 per day) WorkOrder -Text- 50 (string of letters and numbers of varying length)-example-KR53103 2625000-48 Badge -text- (employee badge number)-example-c12345
7
3133
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. When I go to the second record nothing happens. I have attached the code below: I bolded text that contains the javascript and fields this is applied to <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!--#include file="Connections/FutureOrders.asp"...
0
10163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
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
9957
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
9835
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
6649
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();...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.