Solved

Date and time

Posted on 2014-04-03
3
327 Views
Last Modified: 2014-04-04
Hi,

I have jquery date and time picker that I want to insert into my database.

My database data type field is datetime. the value for the text field is "04/03/2014 12:51 pm"

how can I convert from this:

 "04/03/2014 1:51 pm"

to  military

 "04/03/2014 13:51"


$('#TimeResolvedTxt').timepicker({
	hourGrid: 4,
	minuteGrid: 10,
	timeFormat: 'hh:mm tt'
});


$('#DateResolvedtxt').datetimepicker({
	timeFormat: "hh:mm tt"
});

Open in new window



 <input id="DateResolvedtxt" name="DateResolvedtxt" data-format="MM/dd/yyyy" type="text" style="height:23px;width:205px;text-align:center;"/>

<input id="TimeResolvedTxt" name="TimeResolvedTxt" data-format="hh:mm:ss" type="text"
     					style="height:23px;width:195px;text-align:center;"/>

Open in new window



 <cfif IsDefined('FORM.DateResolvedtxt') and isDate(form.DateResolvedtxt)>
      <cfqueryparam value="#form.DateResolvedtxt#" cfsqltype="cf_sql_timestamp"> ,
<cfelse>
      NULL ,
</cfif> 

Open in new window

0
Comment
Question by:lulu50
3 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39975933
Are you trying to put the date and time to an input field from your database?  Wouldn't be easier to use you server side code to parse this out?

I have used keith wood's site for this (and a few other things) http://keith-wood.name/timeEntry.html  The jquery plug in is ready to go.  
('#show24').timeEntry({show24Hours: true});

Open in new window

0
 
LVL 15

Accepted Solution

by:
Gurpreet Singh Randhawa earned 500 total points
ID: 39977372
Use your server side to do what you are trying to here

if you are using coldfusion 10:

<cfif IsDefined('FORM.DateResolvedtxt') and isDate(form.DateResolvedtxt)>
      <cfqueryparam value="#DateTimeFormat(form.DateResolvedtxt,'mm/dd/yyyy HH:nn')#" cfsqltype="cf_sql_timestamp"> ,
<cfelse>
      NULL ,
</cfif>

Open in new window


If you are on Coldfusion 9 or below do like this:

<cfif IsDefined('FORM.DateResolvedtxt') and isDate(form.DateResolvedtxt)>
<cfset dt = DateFormat(form.DateResolvedtxt,'mm/dd/yyyy') & TimeFormat(form.DateResolvedtxt,'HH:mm')>
      <cfqueryparam value="#dt#" cfsqltype="cf_sql_timestamp"> ,
<cfelse>
      NULL ,
</cfif> 

Open in new window

0
 

Author Closing Comment

by:lulu50
ID: 39978091
Thank you
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now