Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Date and time

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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…

839 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