Solved

Date and time

Posted on 2014-04-03
3
321 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

744 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

11 Experts available now in Live!

Get 1:1 Help Now